pub struct Instant { /* private fields */ }Expand description
A no_std-friendly stand-in for std::time::Instant.
- If the target has 64-bit atomics,
Instant::now()is monotonic-ish (a counter). - Otherwise,
Instant::now()is always the same instant (so elapsed = 0).
This is meant as a compile-time fallback, not a real clock.
Implementations§
Source§impl Instant
impl Instant
Sourcepub fn elapsed(&self) -> Duration
pub fn elapsed(&self) -> Duration
Returns the amount of time elapsed since this instant was created.
Sourcepub fn duration_since(&self, earlier: Instant) -> Duration
pub fn duration_since(&self, earlier: Instant) -> Duration
Returns the duration between two instants, or panics if earlier is later than self.
Sourcepub fn checked_duration_since(&self, earlier: Instant) -> Option<Duration>
pub fn checked_duration_since(&self, earlier: Instant) -> Option<Duration>
Returns the duration between two instants, or None if earlier is later than self.
Sourcepub fn saturating_duration_since(&self, earlier: Instant) -> Duration
pub fn saturating_duration_since(&self, earlier: Instant) -> Duration
Returns the duration between two instants, saturating at zero if earlier is later than self.
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 it does not overflow.
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 it does not underflow.
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)
Performs the
+= operation. Read moreSource§impl Ord for Instant
impl Ord 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)
Performs the
-= operation. Read moreimpl Copy for Instant
impl Eq for Instant
impl StructuralPartialEq for Instant
Auto Trait Implementations§
impl Freeze for Instant
impl RefUnwindSafe for Instant
impl Send for Instant
impl Sync for Instant
impl Unpin for Instant
impl UnsafeUnpin for Instant
impl UnwindSafe for Instant
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more