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: boolHas the chronometer started yet
paused: boolIs the chronometer in pause mode
Implementations
Create a new Chronometer
Examples
Basic usage:
use chronometer::Chronometer;
let mut chrono = Chronometer::new();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![],
// }