Represents a span of time.
Duration is signed, so it can support both positive and negative durations. It is assumed
to always be normalized, i.e. 0 ≤ nanos < NANOS_PER_SEC.
Example
use std::time::Duration;
let d = Duration::zero();
d = d.add(&Duration::from_nanos(700000000));
d = d.sub(&Duration::from_micros(200000));
d = d.add(&Duration::from_millis(1500));
assert_eq!(d, Duration::from_secs(2));
Run this example
Fields
Methods
impl Duration { ... }
-
-
fn zero() -> Duration
A duration of zero time
-
Returns
trueif duration is negative,falseotherwise -
Duration from a specified number of seconds
-
Duration from a specified number of milliseconds
-
Duration from a specified number of microseconds
-
Duration from a specified number of nanoseconds
-
Add a duration to another.
-
Subtract a duration from the current duration.
-
Total number of seconds as a floating point.
Mixins
impl Duration { ... }
-
mixin Comparable<Duration>
-
Returns
trueiflhsnot equal torhs,falseotherwise -
Returns
trueiflhsis strictly less thanrhs,falseotherwise -
Returns
trueiflhsis less or equal torhs,falseotherwise -
Returns
trueiflhsstrictly greater thanrhs,falseotherwise -
Returns
trueiflhsgreater than or equalrhs,falseotherwise -