Skip to main content

block_on

Function block_on 

Source
pub fn block_on<F: Future>(future: F) -> F::Output
Expand description

Runs a future to completion by polling it, for futures that never wait on I/O.

A driver over a scripted bus finishes its read or apply in one poll, so a test needs no executor to await it. A future that is genuinely pending is polled again without yielding, so this is not for futures that wait on a timer or a socket.

§Arguments

  • future - the future to run.

§Returns

The future’s output.

§Examples

use pamoja_hal::script::block_on;

let answer = block_on(async { 6 * 7 });
assert_eq!(answer, 42);