@@ -209,7 +209,6 @@ impl Duration {
209
209
///
210
210
/// [`subsec_nanos`]: #method.subsec_nanos
211
211
#[ stable( feature = "duration" , since = "1.3.0" ) ]
212
- #[ rustc_const_unstable( feature="duration_getters" ) ]
213
212
#[ inline]
214
213
pub const fn as_secs ( & self ) -> u64 { self . secs }
215
214
@@ -229,7 +228,6 @@ impl Duration {
229
228
/// assert_eq!(duration.subsec_millis(), 432);
230
229
/// ```
231
230
#[ stable( feature = "duration_extras" , since = "1.27.0" ) ]
232
- #[ rustc_const_unstable( feature="duration_getters" ) ]
233
231
#[ inline]
234
232
pub const fn subsec_millis ( & self ) -> u32 { self . nanos / NANOS_PER_MILLI }
235
233
@@ -249,7 +247,6 @@ impl Duration {
249
247
/// assert_eq!(duration.subsec_micros(), 234_567);
250
248
/// ```
251
249
#[ stable( feature = "duration_extras" , since = "1.27.0" ) ]
252
- #[ rustc_const_unstable( feature="duration_getters" ) ]
253
250
#[ inline]
254
251
pub const fn subsec_micros ( & self ) -> u32 { self . nanos / NANOS_PER_MICRO }
255
252
@@ -269,7 +266,6 @@ impl Duration {
269
266
/// assert_eq!(duration.subsec_nanos(), 10_000_000);
270
267
/// ```
271
268
#[ stable( feature = "duration" , since = "1.3.0" ) ]
272
- #[ rustc_const_unstable( feature="duration_getters" ) ]
273
269
#[ inline]
274
270
pub const fn subsec_nanos ( & self ) -> u32 { self . nanos }
275
271
@@ -286,7 +282,7 @@ impl Duration {
286
282
/// ```
287
283
#[ unstable( feature = "duration_as_u128" , issue = "50202" ) ]
288
284
#[ inline]
289
- pub fn as_millis ( & self ) -> u128 {
285
+ pub const fn as_millis ( & self ) -> u128 {
290
286
self . secs as u128 * MILLIS_PER_SEC as u128 + ( self . nanos / NANOS_PER_MILLI ) as u128
291
287
}
292
288
@@ -303,7 +299,7 @@ impl Duration {
303
299
/// ```
304
300
#[ unstable( feature = "duration_as_u128" , issue = "50202" ) ]
305
301
#[ inline]
306
- pub fn as_micros ( & self ) -> u128 {
302
+ pub const fn as_micros ( & self ) -> u128 {
307
303
self . secs as u128 * MICROS_PER_SEC as u128 + ( self . nanos / NANOS_PER_MICRO ) as u128
308
304
}
309
305
@@ -320,7 +316,7 @@ impl Duration {
320
316
/// ```
321
317
#[ unstable( feature = "duration_as_u128" , issue = "50202" ) ]
322
318
#[ inline]
323
- pub fn as_nanos ( & self ) -> u128 {
319
+ pub const fn as_nanos ( & self ) -> u128 {
324
320
self . secs as u128 * NANOS_PER_SEC as u128 + self . nanos as u128
325
321
}
326
322
@@ -478,7 +474,7 @@ impl Duration {
478
474
/// ```
479
475
#[ unstable( feature = "duration_float" , issue = "54361" ) ]
480
476
#[ inline]
481
- pub fn as_float_secs ( & self ) -> f64 {
477
+ pub const fn as_float_secs ( & self ) -> f64 {
482
478
( self . secs as f64 ) + ( self . nanos as f64 ) / ( NANOS_PER_SEC as f64 )
483
479
}
484
480
0 commit comments