File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -21,8 +21,6 @@ const NANOS_PER_MILLI: u32 = 1_000_000;
2121const NANOS_PER_MICRO : u32 = 1_000 ;
2222const MILLIS_PER_SEC : u64 = 1_000 ;
2323const MICROS_PER_SEC : u64 = 1_000_000 ;
24- const MAX_NANOS_F64 : f64 = ( ( u64:: MAX as u128 + 1 ) * ( NANOS_PER_SEC as u128 ) ) as f64 ;
25- const MAX_NANOS_F32 : f64 = ( ( u64:: MAX as u128 + 1 ) * ( NANOS_PER_SEC as u128 ) ) as f32 ;
2624
2725/// A `Duration` type to represent a span of time, typically used for system
2826/// timeouts.
@@ -554,6 +552,8 @@ impl Duration {
554552 #[ unstable( feature = "duration_float" , issue = "54361" ) ]
555553 #[ inline]
556554 pub fn from_secs_f64 ( secs : f64 ) -> Duration {
555+ const MAX_NANOS_F64 : f64 =
556+ ( ( u64:: MAX as u128 + 1 ) * ( NANOS_PER_SEC as u128 ) ) as f64 ;
557557 let nanos = secs * ( NANOS_PER_SEC as f64 ) ;
558558 if !nanos. is_finite ( ) {
559559 panic ! ( "got non-finite value when converting float to duration" ) ;
@@ -588,6 +588,8 @@ impl Duration {
588588 #[ unstable( feature = "duration_float" , issue = "54361" ) ]
589589 #[ inline]
590590 pub fn from_secs_f32 ( secs : f32 ) -> Duration {
591+ const MAX_NANOS_F32 : f32 =
592+ ( ( u64:: MAX as u128 + 1 ) * ( NANOS_PER_SEC as u128 ) ) as f32 ;
591593 let nanos = secs * ( NANOS_PER_SEC as f32 ) ;
592594 if !nanos. is_finite ( ) {
593595 panic ! ( "got non-finite value when converting float to duration" ) ;
You can’t perform that action at this time.
0 commit comments