@@ -756,7 +756,7 @@ impl Duration {
756
756
} else if nanos >= MAX_NANOS_F64 {
757
757
Err ( FromSecsError { kind : FromSecsErrorKind :: Overflow } )
758
758
} else if nanos < 0.0 {
759
- Err ( FromSecsError { kind : FromSecsErrorKind :: Underflow } )
759
+ Err ( FromSecsError { kind : FromSecsErrorKind :: Negative } )
760
760
} else {
761
761
let nanos = nanos as u128 ;
762
762
Ok ( Duration {
@@ -818,7 +818,7 @@ impl Duration {
818
818
} else if nanos >= MAX_NANOS_F32 {
819
819
Err ( FromSecsError { kind : FromSecsErrorKind :: Overflow } )
820
820
} else if nanos < 0.0 {
821
- Err ( FromSecsError { kind : FromSecsErrorKind :: Underflow } )
821
+ Err ( FromSecsError { kind : FromSecsErrorKind :: Negative } )
822
822
} else {
823
823
let nanos = nanos as u128 ;
824
824
Ok ( Duration {
@@ -1274,11 +1274,9 @@ pub struct FromSecsError {
1274
1274
impl FromSecsError {
1275
1275
const fn description ( & self ) -> & ' static str {
1276
1276
match self . kind {
1277
- FromSecsErrorKind :: NonFinite => {
1278
- "got non-finite value when converting float to duration"
1279
- }
1277
+ FromSecsErrorKind :: NonFinite => "non-finite value when converting float to duration" ,
1280
1278
FromSecsErrorKind :: Overflow => "overflow when converting float to duration" ,
1281
- FromSecsErrorKind :: Underflow => "underflow when converting float to duration" ,
1279
+ FromSecsErrorKind :: Negative => "negative value when converting float to duration" ,
1282
1280
}
1283
1281
}
1284
1282
}
@@ -1292,10 +1290,10 @@ impl fmt::Display for FromSecsError {
1292
1290
1293
1291
#[ derive( Debug , Clone , PartialEq , Eq ) ]
1294
1292
enum FromSecsErrorKind {
1295
- // Value is not a finite value (either infinity or NaN).
1293
+ // Value is not a finite value (either + or - infinity or NaN).
1296
1294
NonFinite ,
1297
1295
// Value is too large to store in a `Duration`.
1298
1296
Overflow ,
1299
- // Value is less than `0.0` .
1300
- Underflow ,
1297
+ // Value is negative .
1298
+ Negative ,
1301
1299
}
0 commit comments