Struct chronometer::Chronometer[][src]

pub struct Chronometer {
    pub laps: Vec<Duration>,
    pub started: bool,
    pub paused: bool,
    // some fields omitted
}

Fields

laps: Vec<Duration>

Vector of all the laps since last reset

started: bool

Has the chronometer started yet

paused: bool

Is the chronometer in pause mode

Implementations

Create a new Chronometer

Examples

Basic usage:

use chronometer::Chronometer;
 
let mut chrono = Chronometer::new();

Start and “unpause” the chronometer

Examples

Basic usage:

chrono.start();

Pause the chronometer

Examples

Basic usage:

chrono.start();
 
let time = time::Duration::from_millis(100);
 
thread::sleep(time);
chrono.pause(); // chrono.duration == Duration<0.1s>
thread::sleep(time);
 
// chrono.duration == Duration<0.1s>
 
chrono.start();
thread::sleep(time);
// chrono.duration == Duration<0.2s>

Add a lap to the chronometer

Examples

Basic usage:

chrono.start();
 
let time = time::Duration::from_millis(100);
 
thread::sleep(time);
 
chrono.lap(); // chono.laps == [Duration<0.1s>, Duration<0.2s>]
 
thread::sleep(time);
 
chrono.lap(); // chono.laps == [Duration<0.1s>, Duration<0.2s>]

Reset the chronometer, useful to restart everything and all the mesurements in your program

Examples

Basic usage:

chrono.start();
 
let time = time::Duration::from_millis(100);
 
thread::sleep(time);
 
chrono.lap(); // chono.laps == [Duration<0.1s>, Duration<0.2s>]
chrono.reset();
// chono == {
//  started: false,
//  paused: false,
//  laps: vec![],
// }

Gets you the elapsed time on your chronometer as a std::time::Duration

Examples

Basic usage:

chrono.start();
 
let time = time::Duration::from_millis(100);
 
thread::sleep(time);
 
println!("elapsed: {}", chrono.duration().as_millis()); // elapsed: 100

Trait Implementations

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.