pub struct Duration { /* private fields */ }Expand description
A signed duration with nanosecond precision.
Implementations§
Source§impl Duration
impl Duration
Sourcepub const fn from_nanos(nanos: i128) -> Duration
pub const fn from_nanos(nanos: i128) -> Duration
Creates a duration from a signed number of nanoseconds.
Sourcepub const fn nanoseconds(nanos: i64) -> Duration
pub const fn nanoseconds(nanos: i64) -> Duration
Creates a duration from a signed number of nanoseconds.
Sourcepub const fn microseconds(micros: i64) -> Duration
pub const fn microseconds(micros: i64) -> Duration
Creates a duration from a signed number of microseconds.
Sourcepub const fn milliseconds(millis: i64) -> Duration
pub const fn milliseconds(millis: i64) -> Duration
Creates a duration from a signed number of milliseconds.
Sourcepub const fn seconds(seconds: i64) -> Duration
pub const fn seconds(seconds: i64) -> Duration
Creates a duration from a signed number of seconds.
Sourcepub const fn minutes(minutes: i64) -> Duration
pub const fn minutes(minutes: i64) -> Duration
Creates a duration from a signed number of minutes.
Sourcepub const fn num_nanoseconds(self) -> Option<i64>
pub const fn num_nanoseconds(self) -> Option<i64>
Returns the total number of nanoseconds, or None if it does not fit in
an i64.
Sourcepub const fn num_seconds(self) -> i64
pub const fn num_seconds(self) -> i64
Returns the number of whole seconds, truncated toward zero.
Sourcepub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
Returns true if this duration is negative.
Sourcepub const fn checked_add(self, other: Duration) -> Option<Duration>
pub const fn checked_add(self, other: Duration) -> Option<Duration>
Adds two durations, returning None on overflow.
Sourcepub const fn checked_sub(self, other: Duration) -> Option<Duration>
pub const fn checked_sub(self, other: Duration) -> Option<Duration>
Subtracts two durations, returning None on overflow.
Trait Implementations§
impl Copy for Duration
impl Eq for Duration
Source§impl Ord for Duration
impl Ord for Duration
1.21.0 (const: unstable) · 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
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Duration
impl PartialOrd for Duration
impl StructuralPartialEq for Duration
Auto Trait Implementations§
impl Freeze for Duration
impl RefUnwindSafe for Duration
impl Send for Duration
impl Sync for Duration
impl Unpin for Duration
impl UnsafeUnpin for Duration
impl UnwindSafe for Duration
Blanket Implementations§
§impl<T> AnyExt for T
impl<T> AnyExt for T
§fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
fn downcast_ref<T>(this: &Self) -> Option<&T>where
T: Any,
Attempts to downcast this to
T behind reference§fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
fn downcast_mut<T>(this: &mut Self) -> Option<&mut T>where
T: Any,
Attempts to downcast this to
T behind mutable reference§fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
fn downcast_rc<T>(this: Rc<Self>) -> Result<Rc<T>, Rc<Self>>where
T: Any,
Attempts to downcast this to
T behind Rc pointer§fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
fn downcast_arc<T>(this: Arc<Self>) -> Result<Arc<T>, Arc<Self>>where
T: Any,
Attempts to downcast this to
T behind Arc pointer§fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
fn downcast_box<T>(this: Box<Self>) -> Result<Box<T>, Box<Self>>where
T: Any,
Attempts to downcast this to
T behind Box pointer§fn downcast_move<T>(this: Self) -> Option<T>
fn downcast_move<T>(this: Self) -> Option<T>
Attempts to downcast owned
Self to T,
useful only in generic context as a workaround for specializationSource§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