Trait InstantExt
trait InstantExt: sealed::Sealed
An extension trait for std::time::Instant that adds methods for
time::Durations.
Required Methods
fn checked_add_signed(self: &Self, duration: Duration) -> Option<Self>Returns
Some(t)wheretis the timeself.checked_add_signed(duration)iftcan be represented asInstant(which means it's inside the bounds of the underlying data structure),Noneotherwise.fn checked_sub_signed(self: &Self, duration: Duration) -> Option<Self>Returns
Some(t)wheretis the timeself.checked_sub_signed(duration)iftcan be represented asInstant(which means it's inside the bounds of the underlying data structure),Noneotherwise.fn signed_duration_since(self: &Self, earlier: Self) -> DurationReturns the amount of time elapsed from another instant to this one. This will be negative if
earlieris later thanself.Example
# use sleep; # use ; # use InstantExt; let now = now; sleep; let new_now = now; println!; // positive println!; // negative
Provided Methods
fn add_signed(self: Self, duration: Duration) -> SelfPanics
This function may panic if the resulting point in time cannot be represented by the underlying data structure. See
InstantExt::checked_add_signedfor a non-panicking version.fn sub_signed(self: Self, duration: Duration) -> SelfPanics
This function may panic if the resulting point in time cannot be represented by the underlying data structure. See
InstantExt::checked_sub_signedfor a non-panicking version.
Implementors
impl InstantExt for Instant