Macro futures_macro_await::await [] [src]

macro_rules! await {
    ($e:expr) => { ... };
}

Await a sub-future inside an #[async] function.

You should pass an object implementing [Future] or [StableFuture] to this macro, it will implicitly yield while that future returns [Async::Pending] and evaluate to a [Result] containing the result of that future once complete.

Examples

This example is not tested
#![feature(proc_macro, generators, pin)]
extern crate futures;

use futures::prelude::*;
use futures::future;
use futures::stable::block_on_stable;

#[async]
fn probably_one() -> Result<u32, u32> {
    let one = await!(future::ok::<u32, u32>(1))?;
    Ok(one)
}

assert_eq!(Ok(1), block_on_stable(probably_one()));