This library provides a very simple, poll based timer.
To use, include the following in Cargo.toml
toml
[dependencies]
simpler_timer = "0.2.0"
```rust use simpler_timer::Timer; use std::time::Duration;
fn main() { let periodic = Timer::withduration(Duration::frommillis(100)); let timeout = Timer::withduration(Duration::fromsecs(2));
loop {
if periodic.expired() {
println!("tick");
periodic.reset();
}
if timeout.expired() {
break;
}
}
println!("total elapsed time: {}ms", timeout.elapsed().as_millis());
} ```