pub struct Duration<Clock>where
Clock: Clock,{ /* private fields */ }Expand description
A span of time represented by a signed tick count.
A Duration is generic over a Clock, preventing arithmetic operations
between durations of different clocks at compile-time.
Implementations§
Source§impl<Clock> Duration<Clock>where
Clock: Clock,
impl<Clock> Duration<Clock>where
Clock: Clock,
Sourcepub const fn from_secs(secs: i64) -> Duration<Clock>
pub const fn from_secs(secs: i64) -> Duration<Clock>
Creates a Duration from a number of seconds.
Sourcepub const fn from_millis(millis: i64) -> Duration<Clock>
pub const fn from_millis(millis: i64) -> Duration<Clock>
Creates a Duration from a number of milliseconds.
Sourcepub const fn from_micros(micros: i64) -> Duration<Clock>
pub const fn from_micros(micros: i64) -> Duration<Clock>
Creates a Duration from a number of microseconds.
Sourcepub const fn from_nanos(nanos: i64) -> Duration<Clock>
pub const fn from_nanos(nanos: i64) -> Duration<Clock>
Creates a Duration from a number of nanoseconds.
Sourcepub const fn checked_add(self, rhs: Duration<Clock>) -> Option<Duration<Clock>>
pub const fn checked_add(self, rhs: Duration<Clock>) -> Option<Duration<Clock>>
Adds another Duration, returning None if overflow occurred.
Sourcepub const fn checked_sub(self, rhs: Duration<Clock>) -> Option<Duration<Clock>>
pub const fn checked_sub(self, rhs: Duration<Clock>) -> Option<Duration<Clock>>
Subtracts another Duration, returning None if underflow occurred.
Trait Implementations§
Source§impl<Clock> Ord for Duration<Clock>where
Clock: Clock,
impl<Clock> Ord for Duration<Clock>where
Clock: Clock,
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl<Clock> PartialOrd for Duration<Clock>where
Clock: Clock,
impl<Clock> PartialOrd for Duration<Clock>where
Clock: Clock,
impl<Clock> Copy for Duration<Clock>where
Clock: Clock,
impl<Clock> Eq for Duration<Clock>where
Clock: Clock,
Auto Trait Implementations§
impl<Clock> Freeze for Duration<Clock>
impl<Clock> RefUnwindSafe for Duration<Clock>where
Clock: RefUnwindSafe,
impl<Clock> Send for Duration<Clock>where
Clock: Send,
impl<Clock> Sync for Duration<Clock>where
Clock: Sync,
impl<Clock> Unpin for Duration<Clock>where
Clock: Unpin,
impl<Clock> UnsafeUnpin for Duration<Clock>
impl<Clock> UnwindSafe for Duration<Clock>where
Clock: UnwindSafe,
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