Expand description
时间量化。
Examples:
有多种方法可以创建新的 Duration
:
let five_seconds = Duration::from_secs(5);
assert_eq!(five_seconds, Duration::from_millis(5_000));
assert_eq!(five_seconds, Duration::from_micros(5_000_000));
assert_eq!(five_seconds, Duration::from_nanos(5_000_000_000));
let ten_seconds = Duration::from_secs(10);
let seven_nanos = Duration::from_nanos(7);
let total = ten_seconds + seven_nanos;
assert_eq!(total, Duration::new(10, 7));
RunStructs
Duration
类型代表时间跨度,通常用于系统超时。- 将秒的浮点值转换为
Duration
时可能返回的错误。