Skip to content

Instantly share code, notes, and snippets.

@bearcage
Created December 31, 2018 22:27
Show Gist options
  • Select an option

  • Save bearcage/c8e6082e47819fb35b09504ff7b7fe99 to your computer and use it in GitHub Desktop.

Select an option

Save bearcage/c8e6082e47819fb35b09504ff7b7fe99 to your computer and use it in GitHub Desktop.
C:\Users\aberg\work\timetest (master -> origin)
λ cargo run
Finished dev [unoptimized + debuginfo] target(s) in 0.02s
Running `target\debug\timetest.exe`
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `4.999914ms`,
right: `5ms`', src\main.rs:6:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
error: process didn't exit successfully: `target\debug\timetest.exe` (exit code: 101)
C:\Users\aberg\work\timetest (master -> origin)
λ cat src\main.rs
use std::time::{Duration, Instant};
fn main() {
let now = Instant::now();
let offset = Duration::from_millis(5);
assert_eq!((now + offset) - now, (now - now) + offset);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment