@@ -756,7 +756,7 @@ impl Duration {
756756 } else if nanos >= MAX_NANOS_F64 {
757757 Err ( FromSecsError { kind : FromSecsErrorKind :: Overflow } )
758758 } else if nanos < 0.0 {
759- Err ( FromSecsError { kind : FromSecsErrorKind :: Underflow } )
759+ Err ( FromSecsError { kind : FromSecsErrorKind :: Negative } )
760760 } else {
761761 let nanos = nanos as u128 ;
762762 Ok ( Duration {
@@ -818,7 +818,7 @@ impl Duration {
818818 } else if nanos >= MAX_NANOS_F32 {
819819 Err ( FromSecsError { kind : FromSecsErrorKind :: Overflow } )
820820 } else if nanos < 0.0 {
821- Err ( FromSecsError { kind : FromSecsErrorKind :: Underflow } )
821+ Err ( FromSecsError { kind : FromSecsErrorKind :: Negative } )
822822 } else {
823823 let nanos = nanos as u128 ;
824824 Ok ( Duration {
@@ -1274,11 +1274,9 @@ pub struct FromSecsError {
12741274impl FromSecsError {
12751275 const fn description ( & self ) -> & ' static str {
12761276 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" ,
12801278 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" ,
12821280 }
12831281 }
12841282}
@@ -1292,10 +1290,10 @@ impl fmt::Display for FromSecsError {
12921290
12931291#[ derive( Debug , Clone , PartialEq , Eq ) ]
12941292enum FromSecsErrorKind {
1295- // Value is not a finite value (either infinity or NaN).
1293+ // Value is not a finite value (either + or - infinity or NaN).
12961294 NonFinite ,
12971295 // Value is too large to store in a `Duration`.
12981296 Overflow ,
1299- // Value is less than `0.0` .
1300- Underflow ,
1297+ // Value is negative .
1298+ Negative ,
13011299}
0 commit comments