pub async fn sleep(dur: Duration)
Expand description
Sleeps for the specified amount of time.
This function might sleep for slightly longer than the specified duration but never less.
This function is an async version of std::thread::sleep
.
See also: stream::interval
.
§Examples
use std::time::Duration;
use async_std::task;
task::sleep(Duration::from_secs(1)).await;