@@ -39,8 +39,8 @@ macro_rules! try_opt(
39
39
#[ deriving( PartialEq , Eq , PartialOrd , Ord ) ]
40
40
pub struct Duration {
41
41
days : i32 ,
42
- secs : u32 ,
43
- nanos : u32 ,
42
+ secs : u32 , // Always < SECS_PER_DAY
43
+ nanos : u32 , // Always < NANOS_PR_SECOND
44
44
}
45
45
46
46
/// The minimum possible `Duration`.
@@ -81,18 +81,13 @@ impl Duration {
81
81
82
82
/// Makes a new `Duration` with given number of days.
83
83
/// Equivalent to `Duration::new(days, 0, 0)`.
84
- ///
85
- /// Fails when the duration is out of bounds.
86
84
#[ inline]
87
85
pub fn days ( days : i32 ) -> Duration {
88
- let days = days. to_i32 ( ) . expect ( "Duration::days out of bounds" ) ;
89
86
Duration { days : days, secs : 0 , nanos : 0 }
90
87
}
91
88
92
89
/// Makes a new `Duration` with given number of hours.
93
90
/// Equivalent to `Duration::new(0, hours * 3600, 0)` with overflow checks.
94
- ///
95
- /// Fails when the duration is out of bounds.
96
91
#[ inline]
97
92
pub fn hours ( hours : i32 ) -> Duration {
98
93
let ( days, hours) = div_mod_floor ( hours, ( SECS_PER_DAY / 3600 ) ) ;
@@ -102,8 +97,6 @@ impl Duration {
102
97
103
98
/// Makes a new `Duration` with given number of minutes.
104
99
/// Equivalent to `Duration::new(0, mins * 60, 0)` with overflow checks.
105
- ///
106
- /// Fails when the duration is out of bounds.
107
100
#[ inline]
108
101
pub fn minutes ( mins : i32 ) -> Duration {
109
102
let ( days, mins) = div_mod_floor ( mins, ( SECS_PER_DAY / 60 ) ) ;
@@ -113,8 +106,6 @@ impl Duration {
113
106
114
107
/// Makes a new `Duration` with given number of seconds.
115
108
/// Equivalent to `Duration::new(0, secs, 0)`.
116
- ///
117
- /// Fails when the duration is out of bounds.
118
109
#[ inline]
119
110
pub fn seconds ( secs : i32 ) -> Duration {
120
111
let ( days, secs) = div_mod_floor ( secs, SECS_PER_DAY ) ;
@@ -123,8 +114,6 @@ impl Duration {
123
114
124
115
/// Makes a new `Duration` with given number of milliseconds.
125
116
/// Equivalent to `Duration::new(0, 0, millis * 1_000_000)` with overflow checks.
126
- ///
127
- /// Fails when the duration is out of bounds.
128
117
#[ inline]
129
118
pub fn milliseconds ( millis : i32 ) -> Duration {
130
119
let ( secs, millis) = div_mod_floor ( millis, ( NANOS_PER_SEC / 1_000_000 ) ) ;
@@ -134,8 +123,6 @@ impl Duration {
134
123
135
124
/// Makes a new `Duration` with given number of microseconds.
136
125
/// Equivalent to `Duration::new(0, 0, micros * 1_000)` with overflow checks.
137
- ///
138
- /// Fails when the duration is out of bounds.
139
126
#[ inline]
140
127
pub fn microseconds ( micros : i32 ) -> Duration {
141
128
let ( secs, micros) = div_mod_floor ( micros, ( NANOS_PER_SEC / 1_000 ) ) ;
@@ -145,8 +132,6 @@ impl Duration {
145
132
146
133
/// Makes a new `Duration` with given number of nanoseconds.
147
134
/// Equivalent to `Duration::new(0, 0, nanos)`.
148
- ///
149
- /// Fails when the duration is out of bounds.
150
135
#[ inline]
151
136
pub fn nanoseconds ( nanos : i32 ) -> Duration {
152
137
let ( secs, nanos) = div_mod_floor ( nanos, NANOS_PER_SEC ) ;
0 commit comments