#[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§
source§impl AddAssign<Time> for Time
impl AddAssign<Time> for Time
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Performs the
+=
operation. Read moresource§impl DivAssign<Position> for Time
impl DivAssign<Position> for Time
source§fn div_assign(&mut self, other: Position)
fn div_assign(&mut self, other: Position)
Performs the
/=
operation. Read moresource§impl DivAssign<Time> for Position
impl DivAssign<Time> for Position
source§fn div_assign(&mut self, other: Time)
fn div_assign(&mut self, other: Time)
Performs the
/=
operation. Read moresource§impl DivAssign<Time> for Time
impl DivAssign<Time> for Time
source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
Performs the
/=
operation. Read moresource§impl MulAssign<Position> for Time
impl MulAssign<Position> for Time
source§fn mul_assign(&mut self, other: Position)
fn mul_assign(&mut self, other: Position)
Performs the
*=
operation. Read moresource§impl MulAssign<Time> for Position
impl MulAssign<Time> for Position
source§fn mul_assign(&mut self, other: Time)
fn mul_assign(&mut self, other: Time)
Performs the
*=
operation. Read moresource§impl MulAssign<Time> for Time
impl MulAssign<Time> for Time
source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
Performs the
*=
operation. Read moresource§impl PartialEq<Time> for Time
impl PartialEq<Time> for Time
source§impl PartialEq<Time> for f64
impl PartialEq<Time> for f64
source§impl PartialOrd<Time> for Time
impl PartialOrd<Time> for Time
1.0.0 · source§fn 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 moresource§impl PartialOrd<Time> for f64
impl PartialOrd<Time> for f64
1.0.0 · source§fn 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 moresource§impl PartialOrd<f64> for Time
impl PartialOrd<f64> for Time
1.0.0 · source§fn 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 moresource§impl SubAssign<Time> for Time
impl SubAssign<Time> for Time
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Performs the
-=
operation. Read more