File tree 1 file changed +4
-2
lines changed
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;
21
21
const NANOS_PER_MICRO : u32 = 1_000 ;
22
22
const MILLIS_PER_SEC : u64 = 1_000 ;
23
23
const 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 ;
26
24
27
25
/// A `Duration` type to represent a span of time, typically used for system
28
26
/// timeouts.
@@ -554,6 +552,8 @@ impl Duration {
554
552
#[ unstable( feature = "duration_float" , issue = "54361" ) ]
555
553
#[ inline]
556
554
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 ;
557
557
let nanos = secs * ( NANOS_PER_SEC as f64 ) ;
558
558
if !nanos. is_finite ( ) {
559
559
panic ! ( "got non-finite value when converting float to duration" ) ;
@@ -588,6 +588,8 @@ impl Duration {
588
588
#[ unstable( feature = "duration_float" , issue = "54361" ) ]
589
589
#[ inline]
590
590
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 ;
591
593
let nanos = secs * ( NANOS_PER_SEC as f32 ) ;
592
594
if !nanos. is_finite ( ) {
593
595
panic ! ( "got non-finite value when converting float to duration" ) ;
You can’t perform that action at this time.
0 commit comments