Crates.io | moniclock |
lib.rs | moniclock |
version | 0.1.0 |
source | src |
created_at | 2020-09-07 06:18:08.115714 |
updated_at | 2020-09-07 06:18:08.115714 |
description | Monotonic clock |
homepage | https://github.com/stephaneyfx/moniclock |
repository | https://github.com/stephaneyfx/moniclock.git |
max_upload_size | |
id | 285617 |
size | 8,290 |
Defines a monotonic clock whose values are instances of Duration
.
std::time::Instant
?Instant
is opaque and cannot be serialized.
let mut clock = moniclock::Clock::new();
let t0 = clock.elapsed();
let sleep_duration = std::time::Duration::from_millis(100);
std::thread::sleep(sleep_duration);
let t1 = clock.elapsed();
assert!(t1 - t0 >= sleep_duration);