Skip to main content

block_on

Function block_on 

Source
pub fn block_on<F>(
    task: impl IntoFuture<IntoFuture = F>,
) -> <F as Future>::Output
where F: Future,
Expand description

Blocks the thread until the task future finishes.

The crate futures-lite is used to execute the task.

ยงExamples

Test a run call:

use zng_task as task;

pub fn run_ok() {
    let r = task::block_on(task::run(async { foo(32).await }));

    r.expect("foo(32) was not Ok");
}