A specific point in time
This is typically a reading from a high-precision monotonic clock and not the wall-clock. It is useful for measuring durations between two points in time.
Example
use std::time::{Instant, Duration};
use std::thread::sleep;
let start = Instant::now();
sleep(Duration::from_millis(500));
assert!(Instant::now().duration_since(&start).total_secs() >= 0.5);
Run this example
Fields
-
#[cfg] spec: timespec
-
#[cfg] inner: u64
Methods
impl Instant { ... }
-
fn now() -> Instant
Current instant
-
Returns time elapsed since an earlier instant.
If
earlieris after the current instant, then a negative duration is returned. -
Add a specific duration to an instant.
-
Subtract a specific duration from an instant.
Mixins
impl Instant { ... }
-
mixin Comparable<Instant>
-
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 -