1 unstable release

0.1.0 Sep 7, 2020

#591 in Date and time

Download history 327/week @ 2024-11-30 131/week @ 2024-12-07 112/week @ 2024-12-14 27/week @ 2024-12-21 54/week @ 2024-12-28 142/week @ 2025-01-04 169/week @ 2025-01-11 88/week @ 2025-01-18 72/week @ 2025-01-25 109/week @ 2025-02-01 73/week @ 2025-02-08 167/week @ 2025-02-15 183/week @ 2025-02-22 167/week @ 2025-03-01 110/week @ 2025-03-08 163/week @ 2025-03-15

630 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