smol/examples/timer-sleep.rs

15 lines
242 B
Rust
Raw Normal View History

2020-02-05 18:56:07 +00:00
use std::time::{Duration, Instant};
2020-02-09 14:32:44 +00:00
use smol::Timer;
2020-02-05 18:56:07 +00:00
fn main() {
2020-02-09 14:32:44 +00:00
smol::run(async {
2020-02-07 10:54:45 +00:00
let start = Instant::now();
2020-02-05 18:56:07 +00:00
let dur = Duration::from_secs(1);
2020-02-09 14:32:44 +00:00
Timer::after(dur).await;
2020-02-05 18:56:07 +00:00
dbg!(start.elapsed());
})
}