duration-macro

Crates.ioduration-macro
lib.rsduration-macro
version0.1.0
sourcesrc
created_at2020-12-27 22:26:12.009923
updated_at2020-12-27 22:26:12.009923
descriptionCompile-time duration parsing
homepagehttps://github.com/mexus/duration-macro/
repositoryhttps://github.com/mexus/duration-macro/
max_upload_size
id328032
size17,366
Denis (mexus)

documentation

https://docs.rs/duration-macro/

README

duration-macro

crates.io docs.rs

Compile-time duration parsing.

use core::time::Duration;
use duration_macro::duration;

assert_eq!(duration!(2 d 1 m), Duration::from_secs(3600 * 24 * 2 + 60 * 1));
assert_eq!(duration!(1 m 2 d), Duration::from_secs(3600 * 24 * 2 + 60 * 1));
assert_eq!(duration!(100 ns), Duration::from_nanos(100));
assert_eq!(duration!({100 * 2} ns), Duration::from_nanos(200));

For more details, please see the [duration!] docs.

License: MIT/Apache-2.0

Commit count: 3

cargo fmt