pub struct Instant(/* private fields */);
Expand description
A measurement of a monotonically nondecreasing clock.
Opaque and useful only with Duration
.
Implementations§
source§impl Instant
impl Instant
sourcepub fn duration_since(&self, earlier: Instant) -> Duration
pub fn duration_since(&self, earlier: Instant) -> Duration
Returns the amount of time elapsed from another instant to this one, or zero duration if that instant is later than this one.
Panics
Previous rust versions panicked when earlier
was later than self
. Currently this
method saturates. Future versions may reintroduce the panic in some circumstances.
sourcepub fn elapsed(&self) -> Duration
pub fn elapsed(&self) -> Duration
Returns the amount of time elapsed since this instant was created.
Panics
Previous rust versions panicked when the current time was earlier than self. Currently this method returns a Duration of zero in that case. Future versions may reintroduce the panic.
sourcepub fn checked_add(&self, duration: Duration) -> Option<Instant>
pub fn checked_add(&self, duration: Duration) -> Option<Instant>
Returns Some(t)
where t
is the time self + duration
if t
can be represented as
Instant
(which means it’s inside the bounds of the underlying data structure), None
otherwise.
sourcepub fn checked_sub(&self, duration: Duration) -> Option<Instant>
pub fn checked_sub(&self, duration: Duration) -> Option<Instant>
Returns Some(t)
where t
is the time self - duration
if t
can be represented as
Instant
(which means it’s inside the bounds of the underlying data structure), None
otherwise.
Trait Implementations§
source§impl AddAssign<Duration> for Instant
impl AddAssign<Duration> for Instant
source§fn add_assign(&mut self, other: Duration)
fn add_assign(&mut self, other: Duration)
+=
operation. Read moresource§impl SubAssign<Duration> for Instant
impl SubAssign<Duration> for Instant
source§fn sub_assign(&mut self, other: Duration)
fn sub_assign(&mut self, other: Duration)
-=
operation. Read more