pub struct Offset { /* private fields */ }
Expand description
Type-safe alias for time value representing an offset.
Implementations§
Source§impl Offset
impl Offset
Sourcepub const fn from_time_zero(delta: Duration) -> Offset
pub const fn from_time_zero(delta: Duration) -> Offset
Given a duration delta
, returns an offset X
such that the
half-open interval [0, X)
has length delta
.
Sourcepub const fn closed_from_time_zero(delta: Duration) -> Offset
pub const fn closed_from_time_zero(delta: Duration) -> Offset
Given a duration delta
, returns an offset X
such that the
closed interval [0, X]
has length delta
.
Sourcepub const fn since_time_zero(self) -> Duration
pub const fn since_time_zero(self) -> Duration
Given an offset X
, returns the length of the half-open
interval [0, X)
.
§Example
let t = Offset::from(10);
assert_eq!(Offset::from_time_zero(t.since_time_zero()), t);
Sourcepub const fn closed_since_time_zero(self) -> Duration
pub const fn closed_since_time_zero(self) -> Duration
Given an offset X
, returns the length of the closed
interval [0, X]
.
§Example
let t = Offset::from(10);
assert_eq!(Offset::closed_from_time_zero(t.closed_since_time_zero()), t);
Sourcepub fn distance_to(self, t: Offset) -> Duration
pub fn distance_to(self, t: Offset) -> Duration
Compute the distance to a later point in time.
§Example:
let a = Offset::from(10);
let b = Offset::from(25);
assert_eq!(a + a.distance_to(b), b);
Trait Implementations§
Source§impl Ord for Offset
impl Ord for Offset
Source§impl PartialOrd for Offset
impl PartialOrd for Offset
impl Copy for Offset
impl Eq for Offset
impl StructuralPartialEq for Offset
Auto Trait Implementations§
impl Freeze for Offset
impl RefUnwindSafe for Offset
impl Send for Offset
impl Sync for Offset
impl Unpin for Offset
impl UnwindSafe for Offset
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more