[][src]Function async_std::task::block_on

pub fn block_on<F, T>(future: F) -> T where
    F: Future<Output = T>, 

Spawns a task and blocks the current thread on its result.

Calling this function is similar to spawning a thread and immediately joining it, except an asynchronous task will be spawned.

See also: task::spawn_blocking.

Examples

use async_std::task;

task::block_on(async {
    println!("Hello, world!");
})