This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -1290,8 +1290,10 @@ macro_rules! try_from_secs {
12901290
12911291 // note that neither `f32`, nor `f64` can represent
12921292 // 0.999_999_999_5 exactly, so the nanos part
1293- // never will be equal to 10^9.
1294- ( 0 , nanos + add_ns as u32 )
1293+ // never will be equal to NANOS_PER_SEC
1294+ let nanos = nanos + add_ns as u32 ;
1295+ debug_assert!( nanos < NANOS_PER_SEC ) ;
1296+ ( 0 , nanos)
12951297 } else if exp < $mant_bits {
12961298 let secs = u64 :: from( mant >> ( $mant_bits - exp) ) ;
12971299 let t = <$double_ty>:: from( ( mant << exp) & MANT_MASK ) ;
@@ -1308,8 +1310,10 @@ macro_rules! try_from_secs {
13081310 let add_ns = !( rem_msb || ( is_even && is_tie) ) ;
13091311
13101312 // neither `f32`, nor `f64` can represent x.999_999_999_5 exactly,
1311- // so the nanos part never will be equal to 10^9
1312- ( secs, nanos + add_ns as u32 )
1313+ // so the nanos part never will be equal to NANOS_PER_SEC
1314+ let nanos = nanos + add_ns as u32 ;
1315+ debug_assert!( nanos < NANOS_PER_SEC ) ;
1316+ ( secs, nanos)
13131317 } else if exp < 64 {
13141318 // the input has no fractional part
13151319 let secs = u64 :: from( mant) << ( exp - $mant_bits) ;
You can’t perform that action at this time.
0 commit comments