@@ -1225,41 +1225,40 @@ impl fmt::Debug for Duration {
1225
1225
/// # Example
1226
1226
///
1227
1227
/// ```
1228
- /// #![feature(duration_checked_float)]
1229
1228
/// use std::time::Duration;
1230
1229
///
1231
1230
/// if let Err(e) = Duration::try_from_secs_f32(-1.0) {
1232
1231
/// println!("Failed conversion to Duration: {e}");
1233
1232
/// }
1234
1233
/// ```
1235
1234
#[ derive( Debug , Clone , PartialEq , Eq ) ]
1236
- #[ unstable ( feature = "duration_checked_float" , issue = "83400 " ) ]
1237
- pub struct FromFloatSecsError {
1238
- kind : FromFloatSecsErrorKind ,
1235
+ #[ stable ( feature = "duration_checked_float" , since = "CURRENT_RUSTC_VERSION " ) ]
1236
+ pub struct TryFromFloatSecsError {
1237
+ kind : TryFromFloatSecsErrorKind ,
1239
1238
}
1240
1239
1241
- impl FromFloatSecsError {
1240
+ impl TryFromFloatSecsError {
1242
1241
const fn description ( & self ) -> & ' static str {
1243
1242
match self . kind {
1244
- FromFloatSecsErrorKind :: Negative => {
1243
+ TryFromFloatSecsErrorKind :: Negative => {
1245
1244
"can not convert float seconds to Duration: value is negative"
1246
1245
}
1247
- FromFloatSecsErrorKind :: OverflowOrNan => {
1246
+ TryFromFloatSecsErrorKind :: OverflowOrNan => {
1248
1247
"can not convert float seconds to Duration: value is either too big or NaN"
1249
1248
}
1250
1249
}
1251
1250
}
1252
1251
}
1253
1252
1254
- #[ unstable ( feature = "duration_checked_float" , issue = "83400 " ) ]
1255
- impl fmt:: Display for FromFloatSecsError {
1253
+ #[ stable ( feature = "duration_checked_float" , since = "CURRENT_RUSTC_VERSION " ) ]
1254
+ impl fmt:: Display for TryFromFloatSecsError {
1256
1255
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
1257
1256
self . description ( ) . fmt ( f)
1258
1257
}
1259
1258
}
1260
1259
1261
1260
#[ derive( Debug , Clone , PartialEq , Eq ) ]
1262
- enum FromFloatSecsErrorKind {
1261
+ enum TryFromFloatSecsErrorKind {
1263
1262
// Value is negative.
1264
1263
Negative ,
1265
1264
// Value is either too big to be represented as `Duration` or `NaN`.
@@ -1280,7 +1279,7 @@ macro_rules! try_from_secs {
1280
1279
const EXP_MASK : $bits_ty = ( 1 << $exp_bits) - 1 ;
1281
1280
1282
1281
if $secs < 0.0 {
1283
- return Err ( FromFloatSecsError { kind: FromFloatSecsErrorKind :: Negative } ) ;
1282
+ return Err ( TryFromFloatSecsError { kind: TryFromFloatSecsErrorKind :: Negative } ) ;
1284
1283
}
1285
1284
1286
1285
let bits = $secs. to_bits( ) ;
@@ -1339,7 +1338,7 @@ macro_rules! try_from_secs {
1339
1338
let secs = u64 :: from( mant) << ( exp - $mant_bits) ;
1340
1339
( secs, 0 )
1341
1340
} else {
1342
- return Err ( FromFloatSecsError { kind: FromFloatSecsErrorKind :: OverflowOrNan } ) ;
1341
+ return Err ( TryFromFloatSecsError { kind: TryFromFloatSecsErrorKind :: OverflowOrNan } ) ;
1343
1342
} ;
1344
1343
1345
1344
Ok ( Duration :: new( secs, nanos) )
@@ -1355,8 +1354,6 @@ impl Duration {
1355
1354
///
1356
1355
/// # Examples
1357
1356
/// ```
1358
- /// #![feature(duration_checked_float)]
1359
- ///
1360
1357
/// use std::time::Duration;
1361
1358
///
1362
1359
/// let res = Duration::try_from_secs_f32(0.0);
@@ -1404,9 +1401,10 @@ impl Duration {
1404
1401
/// let res = Duration::try_from_secs_f32(val);
1405
1402
/// assert_eq!(res, Ok(Duration::new(1, 2_929_688)));
1406
1403
/// ```
1407
- #[ unstable( feature = "duration_checked_float" , issue = "83400" ) ]
1404
+ #[ stable( feature = "duration_checked_float" , since = "CURRENT_RUSTC_VERSION" ) ]
1405
+ #[ rustc_const_unstable( feature = "duration_consts_float" , issue = "72440" ) ]
1408
1406
#[ inline]
1409
- pub const fn try_from_secs_f32 ( secs : f32 ) -> Result < Duration , FromFloatSecsError > {
1407
+ pub const fn try_from_secs_f32 ( secs : f32 ) -> Result < Duration , TryFromFloatSecsError > {
1410
1408
try_from_secs ! (
1411
1409
secs = secs,
1412
1410
mantissa_bits = 23 ,
@@ -1425,8 +1423,6 @@ impl Duration {
1425
1423
///
1426
1424
/// # Examples
1427
1425
/// ```
1428
- /// #![feature(duration_checked_float)]
1429
- ///
1430
1426
/// use std::time::Duration;
1431
1427
///
1432
1428
/// let res = Duration::try_from_secs_f64(0.0);
@@ -1482,9 +1478,10 @@ impl Duration {
1482
1478
/// let res = Duration::try_from_secs_f64(val);
1483
1479
/// assert_eq!(res, Ok(Duration::new(1, 2_929_688)));
1484
1480
/// ```
1485
- #[ unstable( feature = "duration_checked_float" , issue = "83400" ) ]
1481
+ #[ stable( feature = "duration_checked_float" , since = "CURRENT_RUSTC_VERSION" ) ]
1482
+ #[ rustc_const_unstable( feature = "duration_consts_float" , issue = "72440" ) ]
1486
1483
#[ inline]
1487
- pub const fn try_from_secs_f64 ( secs : f64 ) -> Result < Duration , FromFloatSecsError > {
1484
+ pub const fn try_from_secs_f64 ( secs : f64 ) -> Result < Duration , TryFromFloatSecsError > {
1488
1485
try_from_secs ! (
1489
1486
secs = secs,
1490
1487
mantissa_bits = 52 ,
0 commit comments