1 unstable release

0.1.0 Sep 7, 2020

#499 in Date and time

Download history 5/week @ 2024-03-13 1/week @ 2024-03-20 11/week @ 2024-03-27 27/week @ 2024-04-03 1/week @ 2024-04-10 5/week @ 2024-04-17 7/week @ 2024-04-24 10/week @ 2024-05-01 149/week @ 2024-05-08 320/week @ 2024-05-15 517/week @ 2024-05-22 393/week @ 2024-05-29 464/week @ 2024-06-05 341/week @ 2024-06-12 510/week @ 2024-06-19 234/week @ 2024-06-26

1,621 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

~215KB