Function maitake::time::sleep

source ·
pub fn sleep(duration: Duration) -> Sleep<'static> 
Expand description

Returns a Future that completes after the specified Duration.

This function uses the global default timer, and the returned Sleep future will live for the 'static lifetime. See the module-level documentation for details on using the global default timer.

§Panics

For a version of this function that does not panic, see try_sleep() instead.

§Examples

use maitake::time;

async fn example() {
    time::sleep(time::Duration::from_secs(1)).await;
    println!("one second has passed!");
}