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
earlier
is 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
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 -