about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2014-08-07 15:45:48 -0700
committerBrian Anderson <banderson@mozilla.com>2014-08-13 11:31:48 -0700
commitc6b02f65589cd3d1e94fd585ad93a5e720789d5a (patch)
treea48504c1a2d439b77fe6b865edd49e3252560f4b /src/libstd
parentee10f3501c1df04a015a5331c8343792e519c7a7 (diff)
downloadrust-c6b02f65589cd3d1e94fd585ad93a5e720789d5a.tar.gz
rust-c6b02f65589cd3d1e94fd585ad93a5e720789d5a.zip
std: Improve Duration comments
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/time/duration.rs19
1 files changed, 2 insertions, 17 deletions
diff --git a/src/libstd/time/duration.rs b/src/libstd/time/duration.rs
index 7f31df96b07..ddec5f8b3b8 100644
--- a/src/libstd/time/duration.rs
+++ b/src/libstd/time/duration.rs
@@ -39,8 +39,8 @@ macro_rules! try_opt(
 #[deriving(PartialEq, Eq, PartialOrd, Ord)]
 pub struct Duration {
     days: i32,
-    secs: u32,
-    nanos: u32,
+    secs: u32,  // Always < SECS_PER_DAY
+    nanos: u32, // Always < NANOS_PR_SECOND
 }
 
 /// The minimum possible `Duration`.
@@ -81,18 +81,13 @@ impl Duration {
 
     /// Makes a new `Duration` with given number of days.
     /// Equivalent to `Duration::new(days, 0, 0)`.
-    ///
-    /// Fails when the duration is out of bounds.
     #[inline]
     pub fn days(days: i32) -> Duration {
-        let days = days.to_i32().expect("Duration::days out of bounds");
         Duration { days: days, secs: 0, nanos: 0 }
     }
 
     /// Makes a new `Duration` with given number of hours.
     /// Equivalent to `Duration::new(0, hours * 3600, 0)` with overflow checks.
-    ///
-    /// Fails when the duration is out of bounds.
     #[inline]
     pub fn hours(hours: i32) -> Duration {
         let (days, hours) = div_mod_floor(hours, (SECS_PER_DAY / 3600));
@@ -102,8 +97,6 @@ impl Duration {
 
     /// Makes a new `Duration` with given number of minutes.
     /// Equivalent to `Duration::new(0, mins * 60, 0)` with overflow checks.
-    ///
-    /// Fails when the duration is out of bounds.
     #[inline]
     pub fn minutes(mins: i32) -> Duration {
         let (days, mins) = div_mod_floor(mins, (SECS_PER_DAY / 60));
@@ -113,8 +106,6 @@ impl Duration {
 
     /// Makes a new `Duration` with given number of seconds.
     /// Equivalent to `Duration::new(0, secs, 0)`.
-    ///
-    /// Fails when the duration is out of bounds.
     #[inline]
     pub fn seconds(secs: i32) -> Duration {
         let (days, secs) = div_mod_floor(secs, SECS_PER_DAY);
@@ -123,8 +114,6 @@ impl Duration {
 
     /// Makes a new `Duration` with given number of milliseconds.
     /// Equivalent to `Duration::new(0, 0, millis * 1_000_000)` with overflow checks.
-    ///
-    /// Fails when the duration is out of bounds.
     #[inline]
     pub fn milliseconds(millis: i32) -> Duration {
         let (secs, millis) = div_mod_floor(millis, (NANOS_PER_SEC / 1_000_000));
@@ -134,8 +123,6 @@ impl Duration {
 
     /// Makes a new `Duration` with given number of microseconds.
     /// Equivalent to `Duration::new(0, 0, micros * 1_000)` with overflow checks.
-    ///
-    /// Fails when the duration is out of bounds.
     #[inline]
     pub fn microseconds(micros: i32) -> Duration {
         let (secs, micros) = div_mod_floor(micros, (NANOS_PER_SEC / 1_000));
@@ -145,8 +132,6 @@ impl Duration {
 
     /// Makes a new `Duration` with given number of nanoseconds.
     /// Equivalent to `Duration::new(0, 0, nanos)`.
-    ///
-    /// Fails when the duration is out of bounds.
     #[inline]
     pub fn nanoseconds(nanos: i32) -> Duration {
         let (secs, nanos) = div_mod_floor(nanos, NANOS_PER_SEC);