pub fn block_on<F>(
task: impl IntoFuture<IntoFuture = F>,
) -> <F as Future>::Outputwhere
F: Future,
Expand description
Blocks the thread until the task
future finishes.
This function is useful for implementing async tests, using it in an app will probably cause the app to stop responding.
The crate futures-lite
is used to execute the task.
§Examples
Test a run
call:
use zng_task as task;
#[test]
pub fn run_ok() {
let r = task::block_on(task::run(async {
foo(32).await
}));
r.expect("foo(32) was not Ok");
}