pub struct Ticks<T: Timeline> { /* private fields */ }Expand description
A distance between two points on timeline T, in its ticks. Signed, because the later point
may be on either side.
Implementations§
Source§impl<T: Timeline> Ticks<T>
impl<T: Timeline> Ticks<T>
Sourcepub const fn is_negative(self) -> bool
pub const fn is_negative(self) -> bool
Whether the distance is backwards.
Sourcepub fn to_duration(self) -> Option<Duration>
pub fn to_duration(self) -> Option<Duration>
The distance as a Duration, or None if it is negative, since a Duration cannot be.
A tick shorter than a nanosecond is truncated towards zero.
Sourcepub fn abs_duration(self) -> Duration
pub fn abs_duration(self) -> Duration
The distance’s length as a Duration, whichever way it points. Truncated towards zero
below a nanosecond.
Sourcepub fn from_duration(duration: Duration) -> Option<Self>
pub fn from_duration(duration: Duration) -> Option<Self>
duration in ticks of T, truncated towards zero, or None if it does not fit.
Sourcepub fn checked_add(self, other: Self) -> Option<Self>
pub fn checked_add(self, other: Self) -> Option<Self>
The sum, or None on overflow.
Sourcepub fn checked_sub(self, other: Self) -> Option<Self>
pub fn checked_sub(self, other: Self) -> Option<Self>
The difference, or None on overflow.
Sourcepub fn checked_neg(self) -> Option<Self>
pub fn checked_neg(self) -> Option<Self>
The distance the other way, or None for the one count that has no opposite.
Trait Implementations§
Source§impl<T: Timeline> AddAssign for Ticks<T>
impl<T: Timeline> AddAssign for Ticks<T>
Source§fn add_assign(&mut self, other: Self)
fn add_assign(&mut self, other: Self)
Performs the
+= operation. Read moreSource§impl<T: Timeline> AddAssign<Ticks<T>> for TimePoint<T>
impl<T: Timeline> AddAssign<Ticks<T>> for TimePoint<T>
Source§fn add_assign(&mut self, ticks: Ticks<T>)
fn add_assign(&mut self, ticks: Ticks<T>)
Performs the
+= operation. Read moreimpl<T: Timeline> Copy for Ticks<T>
impl<T: Timeline> Eq for Ticks<T>
Source§impl<T: Timeline> Ord for Ticks<T>
impl<T: Timeline> Ord for Ticks<T>
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<T: Timeline> PartialOrd for Ticks<T>
impl<T: Timeline> PartialOrd for Ticks<T>
Auto Trait Implementations§
impl<T> Freeze for Ticks<T>
impl<T> RefUnwindSafe for Ticks<T>
impl<T> Send for Ticks<T>
impl<T> Sync for Ticks<T>
impl<T> Unpin for Ticks<T>
impl<T> UnsafeUnpin for Ticks<T>
impl<T> UnwindSafe for Ticks<T>
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