Skip to content

Commit d0fb350

Browse files
tiifRalfJung
andcommitted
Add comment for u128 to u64 conversion.
Co-authored-by: Ralf Jung <post@ralfj.de>
1 parent aa83235 commit d0fb350

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/tools/miri/src/clock.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ impl Instant {
4040
InstantKind::Virtual { nanoseconds: earlier },
4141
) => {
4242
let duration = nanoseconds.saturating_sub(earlier);
43+
// `Duration` does not provide a nice constructor from a `u128` of nanoseconds,
44+
// so we have to implement this ourselves.
4345
// It is possible for second to overflow because u64::MAX < (u128::MAX / 1e9).
4446
let seconds = u64::try_from(duration.saturating_div(1_000_000_000)).unwrap();
4547
// It is impossible for nanosecond to overflow because u32::MAX > 1e9.

0 commit comments

Comments
 (0)