@@ -73,7 +73,7 @@ impl Duration {
73
73
/// ```
74
74
#[ stable( feature = "duration" , since = "1.3.0" ) ]
75
75
#[ inline]
76
- pub const fn new ( secs : u64 , nanos : u32 ) -> Duration {
76
+ pub fn new ( secs : u64 , nanos : u32 ) -> Duration {
77
77
let secs = secs. checked_add ( ( nanos / NANOS_PER_SEC ) as u64 )
78
78
. expect ( "overflow in Duration::new" ) ;
79
79
let nanos = nanos % NANOS_PER_SEC ;
@@ -113,9 +113,10 @@ impl Duration {
113
113
#[ stable( feature = "duration" , since = "1.3.0" ) ]
114
114
#[ inline]
115
115
pub const fn from_millis ( millis : u64 ) -> Duration {
116
- let secs = millis / MILLIS_PER_SEC ;
117
- let nanos = ( ( millis % MILLIS_PER_SEC ) as u32 ) * NANOS_PER_MILLI ;
118
- Duration { secs : secs, nanos : nanos }
116
+ Duration {
117
+ secs : millis / MILLIS_PER_SEC ,
118
+ nanos : ( ( millis % MILLIS_PER_SEC ) as u32 ) * NANOS_PER_MILLI ,
119
+ }
119
120
}
120
121
121
122
/// Creates a new `Duration` from the specified number of microseconds.
@@ -134,9 +135,10 @@ impl Duration {
134
135
#[ unstable( feature = "duration_from_micros" , issue = "44400" ) ]
135
136
#[ inline]
136
137
pub const fn from_micros ( micros : u64 ) -> Duration {
137
- let secs = micros / MICROS_PER_SEC ;
138
- let nanos = ( ( micros % MICROS_PER_SEC ) as u32 ) * NANOS_PER_MICRO ;
139
- Duration { secs : secs, nanos : nanos }
138
+ Duration {
139
+ secs : micros / MICROS_PER_SEC ,
140
+ nanos : ( ( micros % MICROS_PER_SEC ) as u32 ) * NANOS_PER_MICRO ,
141
+ }
140
142
}
141
143
142
144
/// Creates a new `Duration` from the specified number of nanoseconds.
@@ -155,9 +157,10 @@ impl Duration {
155
157
#[ unstable( feature = "duration_extras" , issue = "46507" ) ]
156
158
#[ inline]
157
159
pub const fn from_nanos ( nanos : u64 ) -> Duration {
158
- let secs = nanos / ( NANOS_PER_SEC as u64 ) ;
159
- let nanos = ( nanos % ( NANOS_PER_SEC as u64 ) ) as u32 ;
160
- Duration { secs : secs, nanos : nanos }
160
+ Duration {
161
+ secs : nanos / ( NANOS_PER_SEC as u64 ) ,
162
+ nanos : ( nanos % ( NANOS_PER_SEC as u64 ) ) as u32 ,
163
+ }
161
164
}
162
165
163
166
/// Returns the number of _whole_ seconds contained by this `Duration`.
0 commit comments