pub trait InstantExt: Sealed {
// Required methods
fn checked_add_signed(&self, duration: Duration) -> Option<Self>;
fn checked_sub_signed(&self, duration: Duration) -> Option<Self>;
fn signed_duration_since(&self, earlier: Self) -> Duration;
// Provided methods
fn add_signed(self, duration: Duration) -> Self { ... }
fn sub_signed(self, duration: Duration) -> Self { ... }
}Expand description
An extension trait for std::time::Instant that adds methods for
time::Durations.
Required Methods§
Sourcefn checked_add_signed(&self, duration: Duration) -> Option<Self>
fn checked_add_signed(&self, duration: Duration) -> Option<Self>
Returns Some(t) where t is the time self.checked_add_signed(duration) if t can be
represented as Instant (which means it’s inside the bounds of the underlying data
structure), None otherwise.
Sourcefn checked_sub_signed(&self, duration: Duration) -> Option<Self>
fn checked_sub_signed(&self, duration: Duration) -> Option<Self>
Returns Some(t) where t is the time self.checked_sub_signed(duration) if t can be
represented as Instant (which means it’s inside the bounds of the underlying data
structure), None otherwise.
Sourcefn signed_duration_since(&self, earlier: Self) -> Duration
fn signed_duration_since(&self, earlier: Self) -> Duration
Returns the amount of time elapsed from another instant to this one. This will be negative
if earlier is later than self.
§Example
Provided Methods§
Sourcefn add_signed(self, duration: Duration) -> Self
fn add_signed(self, duration: Duration) -> Self
§Panics
This function may panic if the resulting point in time cannot be represented by the
underlying data structure. See InstantExt::checked_add_signed for a non-panicking
version.
Sourcefn sub_signed(self, duration: Duration) -> Self
fn sub_signed(self, duration: Duration) -> Self
§Panics
This function may panic if the resulting point in time cannot be represented by the
underlying data structure. See InstantExt::checked_sub_signed for a non-panicking
version.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.