Skip to content

Commit 3b3d95a

Browse files
authored
Fix cast in performance API example (#2634)
Rust 1.45 defines (f64 as u32) as a saturating cast. The millis was incorrectly always 295 (u32::MAX % 1000).
1 parent b97837b commit 3b3d95a

File tree

1 file changed

+1
-1
lines changed
  • examples/performance/src

1 file changed

+1
-1
lines changed

examples/performance/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ pub fn run() {
3131

3232
fn perf_to_system(amt: f64) -> SystemTime {
3333
let secs = (amt as u64) / 1_000;
34-
let nanos = ((amt as u32) % 1_000) * 1_000_000;
34+
let nanos = (((amt as u64) % 1_000) as u32) * 1_000_000;
3535
UNIX_EPOCH + Duration::new(secs, nanos)
3636
}

0 commit comments

Comments
 (0)