pub trait TimePoint:
Copy
+ Ord
+ Add<Self::Span, Output = Self>
+ Sub<Output = Self::Span> {
type Span: Copy + Ord;
// Required methods
fn from_count(count: i64) -> Self;
fn count(self) -> i64;
}Expand description
A point on one timeline, carried as a count of its unit since the timeline’s origin, with the span between two of them.
Every point here implements it, and so may a type of your own that wraps one, to work with code generic over points.
§Examples
use t2t_core::{TimePoint, Timedelta, Timestamp};
fn age<P: TimePoint>(stamp: P, now: P) -> P::Span {
now - stamp
}
let stamp = Timestamp::from_secs(10);
assert_eq!(age(stamp, stamp + Timedelta::SECOND), Timedelta::SECOND, "any point's age");
assert_eq!(Timestamp::from_count(stamp.count()), stamp, "and its count round trips");Required Associated Types§
Required Methods§
Sourcefn from_count(count: i64) -> Self
fn from_count(count: i64) -> Self
The point count units after the origin.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".