Struct axstd::time::Instant

source ·
pub struct Instant(/* private fields */);
Expand description

A measurement of a monotonically nondecreasing clock. Opaque and useful only with Duration.

Implementations§

source§

impl Instant

source

pub fn now() -> Instant

Returns an instant corresponding to “now”.

source

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.

source

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.

source

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.

source

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 Add<Duration> for Instant

source§

fn add(self, other: Duration) -> Instant

Panics

This function may panic if the resulting point in time cannot be represented by the underlying data structure.

§

type Output = Instant

The resulting type after applying the + operator.
source§

impl AddAssign<Duration> for Instant

source§

fn add_assign(&mut self, other: Duration)

Performs the += operation. Read more
source§

impl Clone for Instant

source§

fn clone(&self) -> Instant

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Sub<Duration> for Instant

§

type Output = Instant

The resulting type after applying the - operator.
source§

fn sub(self, other: Duration) -> Instant

Performs the - operation. Read more
source§

impl Sub for Instant

source§

fn sub(self, other: 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.

§

type Output = Duration

The resulting type after applying the - operator.
source§

impl SubAssign<Duration> for Instant

source§

fn sub_assign(&mut self, other: Duration)

Performs the -= operation. Read more
source§

impl Copy for Instant

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> AsAny for T
where T: Any,

source§

fn as_any(&self) -> &(dyn Any + 'static)

把当前对象转化为 Any 类型,供后续 downcast 使用
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

供 downcast_mut 使用
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.