#[repr(transparent)]pub struct Time(_);
Expand description
A newtype for the concept of time.
A Time
value can represent either a point in time
or the output of arithmetic involving time.
Wraps f64
.
Examples
let t0 = tskit::Time::from(2.0);
let t1 = tskit::Time::from(10.0);
let mut sum = t0 + t1;
match sum.partial_cmp(&12.0) {
Some(std::cmp::Ordering::Equal) => (),
_ => assert!(false),
};
sum /= tskit::Time::from(2.0);
match sum.partial_cmp(&6.0) {
Some(std::cmp::Ordering::Equal) => (),
_ => assert!(false),
};
Notes
The current implementation of PartialOrd
is based on
the underlying implementation for f64
.
A Time
can be multiplied and divided by a Position
Trait Implementations
sourceimpl AddAssign<Time> for Time
impl AddAssign<Time> for Time
sourcefn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moresourceimpl DivAssign<Position> for Time
impl DivAssign<Position> for Time
sourcefn div_assign(&mut self, other: Position)
fn div_assign(&mut self, other: Position)
Performs the
/=
operation. Read moresourceimpl DivAssign<Time> for Position
impl DivAssign<Time> for Position
sourcefn div_assign(&mut self, other: Time)
fn div_assign(&mut self, other: Time)
Performs the
/=
operation. Read moresourceimpl DivAssign<Time> for Time
impl DivAssign<Time> for Time
sourcefn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the
/=
operation. Read moresourceimpl MulAssign<Position> for Time
impl MulAssign<Position> for Time
sourcefn mul_assign(&mut self, other: Position)
fn mul_assign(&mut self, other: Position)
Performs the
*=
operation. Read moresourceimpl MulAssign<Time> for Position
impl MulAssign<Time> for Position
sourcefn mul_assign(&mut self, other: Time)
fn mul_assign(&mut self, other: Time)
Performs the
*=
operation. Read moresourceimpl MulAssign<Time> for Time
impl MulAssign<Time> for Time
sourcefn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*=
operation. Read moresourceimpl PartialOrd<Time> for Time
impl PartialOrd<Time> for Time
sourcefn partial_cmp(&self, other: &Time) -> Option<Ordering>
fn partial_cmp(&self, other: &Time) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresourceimpl PartialOrd<Time> for f64
impl PartialOrd<Time> for f64
sourcefn partial_cmp(&self, other: &Time) -> Option<Ordering>
fn partial_cmp(&self, other: &Time) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresourceimpl PartialOrd<f64> for Time
impl PartialOrd<f64> for Time
sourcefn partial_cmp(&self, other: &f64) -> Option<Ordering>
fn partial_cmp(&self, other: &f64) -> Option<Ordering>
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresourceimpl SubAssign<Time> for Time
impl SubAssign<Time> for Time
sourcefn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-=
operation. Read moreimpl Copy for Time
impl StructuralPartialEq for Time
Auto Trait Implementations
impl RefUnwindSafe for Time
impl Send for Time
impl Sync for Time
impl Unpin for Time
impl UnwindSafe for Time
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more