#[repr(transparent)]#[doc(hidden)] pub struct Instant(pub Instant);
std::time::Instant
and time::ext::InstantExt
insteadstd
only.Expand description
A measurement of a monotonically non-decreasing clock. Opaque and useful only with Duration
.
Instants are always guaranteed to be no less than any previously measured instant when created, and are often useful for tasks such as measuring benchmarks or timing how long an operation takes.
Note, however, that instants are not guaranteed to be steady. In other words, each tick of the underlying clock may not be the same length (e.g. some seconds may be longer than others). An instant may jump forwards or experience time dilation (slow down or speed up), but it will never go backwards.
Instants are opaque types that can only be compared to one another. There is no method to get โthe number of secondsโ from an instant. Instead, it only allows measuring the duration between two instants (or comparing two instants).
This implementation allows for operations with signed Duration
s, but is otherwise identical
to std::time::Instant
.
Tuple Fieldsยง
ยง0: Instant
std::time::Instant
and time::ext::InstantExt
insteadImplementationsยง
Sourceยงimpl Instant
impl Instant
Sourcepub fn checked_add(self, duration: Duration) -> Option<Self>
pub fn checked_add(self, duration: Duration) -> Option<Self>
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<Self>
pub fn checked_sub(self, duration: Duration) -> Option<Self>
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 const fn into_inner(self) -> StdInstant
pub const fn into_inner(self) -> StdInstant
Obtain the inner std::time::Instant
.
Trait Implementationsยง
Sourceยงimpl AddAssign<Duration> for Instant
impl AddAssign<Duration> for Instant
Sourceยงfn add_assign(&mut self, rhs: Duration)
fn add_assign(&mut self, rhs: Duration)
+=
operation. Read moreSourceยงimpl AddAssign<Duration> for Instant
impl AddAssign<Duration> for Instant
Sourceยงfn add_assign(&mut self, rhs: StdDuration)
fn add_assign(&mut self, rhs: StdDuration)
+=
operation. Read moreSourceยงimpl AsRef<Instant> for Instant
impl AsRef<Instant> for Instant
Sourceยงfn as_ref(&self) -> &StdInstant
fn as_ref(&self) -> &StdInstant
Sourceยงimpl Borrow<Instant> for Instant
impl Borrow<Instant> for Instant
Sourceยงfn borrow(&self) -> &StdInstant
fn borrow(&self) -> &StdInstant
Sourceยงimpl From<Instant> for Instant
impl From<Instant> for Instant
Sourceยงfn from(instant: StdInstant) -> Self
fn from(instant: StdInstant) -> Self
Sourceยงimpl Ord for Instant
impl Ord for Instant
1.21.0 ยท Sourceยงfn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Sourceยงimpl PartialOrd<Instant> for Instant
impl PartialOrd<Instant> for Instant
Sourceยงimpl PartialOrd<Instant> for Instant
impl PartialOrd<Instant> for Instant
Sourceยงimpl PartialOrd for Instant
impl PartialOrd for Instant
Sourceยงimpl SubAssign<Duration> for Instant
impl SubAssign<Duration> for Instant
Sourceยงfn sub_assign(&mut self, rhs: Duration)
fn sub_assign(&mut self, rhs: Duration)
-=
operation. Read moreSourceยงimpl SubAssign<Duration> for Instant
impl SubAssign<Duration> for Instant
Sourceยงfn sub_assign(&mut self, rhs: StdDuration)
fn sub_assign(&mut self, rhs: StdDuration)
-=
operation. Read more