Crates.io | duration-macro |
lib.rs | duration-macro |
version | 0.1.0 |
source | src |
created_at | 2020-12-27 22:26:12.009923 |
updated_at | 2020-12-27 22:26:12.009923 |
description | Compile-time duration parsing |
homepage | https://github.com/mexus/duration-macro/ |
repository | https://github.com/mexus/duration-macro/ |
max_upload_size | |
id | 328032 |
size | 17,366 |
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