1 unstable release
0.1.0 | Dec 27, 2020 |
---|
#26 in #duration-parser
7KB
53 lines
duration-macro
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
lib.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.