Skip to main content

FutureExt

Trait FutureExt 

Source
pub trait FutureExt: Future {
    // Required method
    fn block_on(self) -> Self::Output;
}
Expand description

An extension trait for Future that provides blocking.

Required Methods§

Source

fn block_on(self) -> Self::Output

Blocks the current thread on this future.

§Panics

Panics if this future panics.

§Examples
use traffic_light::future::FutureExt as _;

let x: result::Result<(), Box<dyn error::Error>> =
    async {
        // ...
        Ok(())
    }.block_on();

assert!(x.is_ok());

Implementors§

Source§

impl<F: Future> FutureExt for F