From bc9de771d5f2ab71a0e3b0eb27a92c65e8ddd4b9 Mon Sep 17 00:00:00 2001 From: Subhash Bhushan Date: Sat, 8 Nov 2014 21:17:51 +0530 Subject: Rename remaining Failures to Panic --- src/libstd/ascii.rs | 5 ++++- src/libstd/c_vec.rs | 4 ++-- src/libstd/sys/windows/tty.rs | 6 +++--- src/libstd/time/duration.rs | 10 +++++----- 4 files changed, 14 insertions(+), 11 deletions(-) (limited to 'src/libstd') diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 923349b1bf7..933794cb5a4 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -216,7 +216,10 @@ pub trait OwnedAsciiCast { /// Check if convertible to ascii fn is_ascii(&self) -> bool; - /// Take ownership and cast to an ascii vector. Fail on non-ASCII input. + /// Take ownership and cast to an ascii vector. + /// # Panics + /// + /// Panic on non-ASCII input. #[inline] fn into_ascii(self) -> Vec { assert!(self.is_ascii()); diff --git a/src/libstd/c_vec.rs b/src/libstd/c_vec.rs index 771184df53d..1267d7411cc 100644 --- a/src/libstd/c_vec.rs +++ b/src/libstd/c_vec.rs @@ -64,7 +64,7 @@ impl Drop for CVec { impl CVec { /// Create a `CVec` from a raw pointer to a buffer with a given length. /// - /// Fails if the given pointer is null. The returned vector will not attempt + /// Panics if the given pointer is null. The returned vector will not attempt /// to deallocate the vector when dropped. /// /// # Arguments @@ -83,7 +83,7 @@ impl CVec { /// Create a `CVec` from a foreign buffer, with a given length, /// and a function to run upon destruction. /// - /// Fails if the given pointer is null. + /// Panics if the given pointer is null. /// /// # Arguments /// diff --git a/src/libstd/sys/windows/tty.rs b/src/libstd/sys/windows/tty.rs index 7d001e6394c..0e7b06cbb94 100644 --- a/src/libstd/sys/windows/tty.rs +++ b/src/libstd/sys/windows/tty.rs @@ -14,8 +14,8 @@ //! //! This module contains the implementation of a Windows specific console TTY. //! Also converts between UTF-16 and UTF-8. Windows has very poor support for -//! UTF-8 and some functions will fail. In particular ReadFile and ReadConsole -//! will fail when the codepage is set to UTF-8 and a Unicode character is +//! UTF-8 and some functions will panic. In particular ReadFile and ReadConsole +//! will panic when the codepage is set to UTF-8 and a Unicode character is //! entered. //! //! FIXME @@ -48,7 +48,7 @@ fn invalid_encoding() -> IoError { pub fn is_tty(fd: c_int) -> bool { let mut out: DWORD = 0; - // If this function doesn't fail then fd is a TTY + // If this function doesn't panic then fd is a TTY match unsafe { GetConsoleMode(get_osfhandle(fd) as HANDLE, &mut out as LPDWORD) } { 0 => false, diff --git a/src/libstd/time/duration.rs b/src/libstd/time/duration.rs index 39ca3128ccb..ec2d62ff85c 100644 --- a/src/libstd/time/duration.rs +++ b/src/libstd/time/duration.rs @@ -65,7 +65,7 @@ pub const MAX: Duration = Duration { impl Duration { /// Makes a new `Duration` with given number of weeks. /// Equivalent to `Duration::seconds(weeks * 7 * 24 * 60 * 60), with overflow checks. - /// Fails when the duration is out of bounds. + /// Panics when the duration is out of bounds. #[inline] pub fn weeks(weeks: i64) -> Duration { let secs = weeks.checked_mul(SECS_PER_WEEK).expect("Duration::weeks out of bounds"); @@ -74,7 +74,7 @@ impl Duration { /// Makes a new `Duration` with given number of days. /// Equivalent to `Duration::seconds(days * 24 * 60 * 60)` with overflow checks. - /// Fails when the duration is out of bounds. + /// Panics when the duration is out of bounds. #[inline] pub fn days(days: i64) -> Duration { let secs = days.checked_mul(SECS_PER_DAY).expect("Duration::days out of bounds"); @@ -83,7 +83,7 @@ impl Duration { /// Makes a new `Duration` with given number of hours. /// Equivalent to `Duration::seconds(hours * 60 * 60)` with overflow checks. - /// Fails when the duration is out of bounds. + /// Panics when the duration is out of bounds. #[inline] pub fn hours(hours: i64) -> Duration { let secs = hours.checked_mul(SECS_PER_HOUR).expect("Duration::hours ouf of bounds"); @@ -92,7 +92,7 @@ impl Duration { /// Makes a new `Duration` with given number of minutes. /// Equivalent to `Duration::seconds(minutes * 60)` with overflow checks. - /// Fails when the duration is out of bounds. + /// Panics when the duration is out of bounds. #[inline] pub fn minutes(minutes: i64) -> Duration { let secs = minutes.checked_mul(SECS_PER_MINUTE).expect("Duration::minutes out of bounds"); @@ -100,7 +100,7 @@ impl Duration { } /// Makes a new `Duration` with given number of seconds. - /// Fails when the duration is more than `i64::MAX` milliseconds + /// Panics when the duration is more than `i64::MAX` milliseconds /// or less than `i64::MIN` milliseconds. #[inline] pub fn seconds(seconds: i64) -> Duration { -- cgit 1.4.1-3-g733a5