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 {
3939 InstantKind :: Virtual { nanoseconds } ,
4040 InstantKind :: Virtual { nanoseconds : earlier } ,
4141 ) => {
42+ let duration = nanoseconds. saturating_sub ( earlier) ;
4243 // 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 ( ) ;
4745 // 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 ( ) ;
4947 Duration :: new ( seconds, nanosecond)
5048 }
5149 _ => panic ! ( "all `Instant` must be of the same kind" ) ,
You can’t perform that action at this time.
0 commit comments