File tree Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Expand file tree Collapse file tree 1 file changed +3
-5
lines changed Original file line number Diff line number Diff line change @@ -39,13 +39,11 @@ impl Instant {
39
39
InstantKind :: Virtual { nanoseconds } ,
40
40
InstantKind :: Virtual { nanoseconds : earlier } ,
41
41
) => {
42
+ let duration = nanoseconds. saturating_sub ( earlier) ;
42
43
// It is possible for second to overflow because u64::MAX < (u128::MAX / 1e9).
43
- let seconds = u64:: try_from (
44
- nanoseconds. saturating_sub ( earlier) . saturating_div ( 1_000_000_000 ) ,
45
- )
46
- . unwrap ( ) ;
44
+ let seconds = u64:: try_from ( duration. saturating_div ( 1_000_000_000 ) ) . unwrap ( ) ;
47
45
// It is impossible for nanosecond to overflow because u32::MAX > 1e9.
48
- let nanosecond = u32:: try_from ( nanoseconds . wrapping_rem ( 1_000_000_000 ) ) . unwrap ( ) ;
46
+ let nanosecond = u32:: try_from ( duration . wrapping_rem ( 1_000_000_000 ) ) . unwrap ( ) ;
49
47
Duration :: new ( seconds, nanosecond)
50
48
}
51
49
_ => panic ! ( "all `Instant` must be of the same kind" ) ,
You can’t perform that action at this time.
0 commit comments