1 unstable release

0.1.0 Sep 7, 2020

#7 in #monotonic

Download history 18/week @ 2023-01-26 17/week @ 2023-02-02 8/week @ 2023-02-09 20/week @ 2023-02-16 11/week @ 2023-02-23 13/week @ 2023-03-02 30/week @ 2023-03-09 13/week @ 2023-03-16 7/week @ 2023-03-23 9/week @ 2023-03-30 27/week @ 2023-04-06 11/week @ 2023-04-13 9/week @ 2023-04-20 41/week @ 2023-04-27 24/week @ 2023-05-04 10/week @ 2023-05-11

87 downloads per month
Used in eliprompt

MIT license

7KB
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

~36KB