Struct aligner::TimeSpan [] [src]

pub struct TimeSpan { /* fields omitted */ }

Represents a time span from "start" (included) to "end" (excluded).

The constructors will ensure "start <= end", this condition will hold at any given time.

Methods

impl TimeSpan
[src]

Create a new TimeSpan with start and end.

Examples

use aligner::{TimeSpan, TimePoint};

let t0 = TimePoint::from(0);
let t10 = TimePoint::from(10);

let ts = TimeSpan::new(t0, t10);

Panics

This function asserts that start is less or equal end.

use aligner::{TimeSpan, TimePoint};

let t0 = TimePoint::from(0);
let t10 = TimePoint::from(10);

// this will case a panic
let ts = TimeSpan::new(t10, t0);

Create a new TimeSpan with start and end. This function will not panic on end < start, but swap the values before calling TimeSpan::new().

Examples

use aligner::{TimeSpan, TimePoint};

let t0 = TimePoint::from(0);
let t10 = TimePoint::from(10);

let ts = TimeSpan::new_safe(t10, t0);
assert!(ts.start() == t0 && ts.end() == t10);

Mutates a TimeSpans end.

Panics

Will panic if new_end is less than current start.

Returns the length of the TimeSpan.

len() is zero, if and only if start is end.

Returns true if start == end.

Returns the start point of the TimeSpan.

Returns the end point of the TimeSpan.

Returns true if self contains TimeSpan other.

Examples

use aligner::{TimeSpan, TimePoint};

Returns the smallest difference between two TimeSpans.

use aligner::{TimeSpan, TimePoint, TimeDelta};

let p = TimePoint::from(0);
let d = TimeDelta::one();

let ts1 = TimeSpan::new(p, p + 10 * d);
let ts4 = TimeSpan::new(p + 20 * d, p + 100 * d);

assert!(TimeSpan::fast_distance_to(ts1, ts1) == 0 * d);
assert!(TimeSpan::fast_distance_to(ts1, ts4) == 10 * d);
assert!(TimeSpan::fast_distance_to(ts4, ts1) == 10 * d);
assert!(TimeSpan::fast_distance_to(ts4, ts4) == 0 * d);

Returns the smallest difference between two TimeSpans.

Compares two TimeSpans by their start timepoint.

Compares two TimeSpans by their end timepoint.

Trait Implementations

impl Copy for TimeSpan
[src]

impl Clone for TimeSpan
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl Debug for TimeSpan
[src]

Formats the value using the given formatter.

impl PartialEq for TimeSpan
[src]

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

impl Eq for TimeSpan
[src]

impl Hash for TimeSpan
[src]

Feeds this value into the state given, updating the hasher as necessary.

Feeds a slice of this type into the state provided.

impl Add<TimeDelta> for TimeSpan
[src]

The resulting type after applying the + operator

The method for the + operator