[go: up one dir, main page]

run

Function run 

Source
pub fn run<F, T>(future: F) -> T
where F: Future<Output = T>,
Expand description

Block the current thread until passed future is resolved with an output (including the panic).

ยงExample

use bastion::executor::run;
let future1 = async move {
    123
};

run(async move {
    let result = future1.await;
    assert_eq!(result, 123);
});

let future2 = async move {
    10 / 2
};

let result = run(future2);
assert_eq!(result, 5);