#[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 more
sourceimpl 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 more
sourceimpl 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 more
sourceimpl 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 more
sourceimpl 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 more
sourceimpl 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 more
sourceimpl 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 more
sourceimpl 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>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
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 more
sourceimpl 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>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
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 more
sourceimpl 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>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
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 more
sourceimpl 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 more
impl 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 T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
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
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more