Function async_std::task::block_on

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

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;

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