Skip to main content

block_on

Function block_on 

pub fn block_on<F>(fut: F) -> <F as IntoFuture>::Output
where F: IntoFuture,
Available on non-WebAssembly only.
Expand description

Drive a future to completion on the calling thread.

The harness’s own entry points already do this, so this is for a synchronous caller that has to build a Ctx itself. It cannot be used on the web, where a browser tab has nothing to block on. Block the thread until the future is ready.

§Example

let my_fut = async {};
let result = pollster::block_on(my_fut);