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
true
if duration is negative,false
otherwise -
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
true
iflhs
not equal torhs
,false
otherwise -
Returns
true
iflhs
is strictly less thanrhs
,false
otherwise -
Returns
true
iflhs
is less or equal torhs
,false
otherwise -
Returns
true
iflhs
strictly greater thanrhs
,false
otherwise -
Returns
true
iflhs
greater than or equalrhs
,false
otherwise -