Skip to main content

ClockAlg

Trait ClockAlg 

Source
pub trait ClockAlg {
    type Moment;

    // Required methods
    fn now(&self) -> Self::Moment;
    fn since(&self, moment: &Self::Moment) -> Duration;
}
Expand description

Specifies reading the passage of time.

Time is read rather than taken, so how long a run has been running is a statement about a clock the interpreter supplies and not about the one this machine happens to have.

Required Associated Types§

Source

type Moment

Represents one reading of the clock.

Required Methods§

Source

fn now(&self) -> Self::Moment

Reads the clock now.

Source

fn since(&self, moment: &Self::Moment) -> Duration

States how long it has been since one reading.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§