1 unstable release

0.1.0 Sep 7, 2020

#565 in Date and time

Download history 206/week @ 2024-07-26 288/week @ 2024-08-02 216/week @ 2024-08-09 332/week @ 2024-08-16 223/week @ 2024-08-23 157/week @ 2024-08-30 167/week @ 2024-09-06 94/week @ 2024-09-13 197/week @ 2024-09-20 187/week @ 2024-09-27 410/week @ 2024-10-04 255/week @ 2024-10-11 188/week @ 2024-10-18 158/week @ 2024-10-25 215/week @ 2024-11-01 255/week @ 2024-11-08

901 downloads per month
Used in eliprompt

MIT license

8KB
138 lines

Crate Docs MIT license

Defines a monotonic clock whose values are instances of Duration.

Why not std::time::Instant?

Instant is opaque and cannot be serialized.

Example

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);

lib.rs:

Defines a monotonic clock whose values are instances of Duration.

Why not std::time::Instant?

Instant is opaque and cannot be serialized.

Example

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);

Dependencies

~220KB