Struct bitflags::__core::time::Duration [] [src]

pub struct Duration {
    // some fields omitted
}
1.3.0
[]

A duration type to represent a span of time, typically used for system timeouts.

Each duration is composed of a number of seconds and nanosecond precision. APIs binding a system timeout will typically round up the nanosecond precision if the underlying system does not support that level of precision.

Durations implement many common traits, including Add, Sub, and other ops traits. Currently a duration may only be inspected for its number of seconds and its nanosecond precision.

Examples

use std::time::Duration;

let five_seconds = Duration::new(5, 0);
let five_seconds_and_five_nanos = five_seconds + Duration::new(0, 5);

assert_eq!(five_seconds_and_five_nanos.as_secs(), 5);
assert_eq!(five_seconds_and_five_nanos.subsec_nanos(), 5);

let ten_millis = Duration::from_millis(10);