Macro futures_macro_await::stream_yield [] [src]

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

Yield an item from an #[async_stream] function.

Examples

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

use futures::prelude::*;
use futures::stream;
use futures::executor::block_on;

#[async_stream(item = u32)]
fn one_five() -> Result<(), u32> {
    stream_yield!(1);
    stream_yield!(5);
    Ok(())
}

assert_eq!(Ok(vec![1, 5]), block_on(one_five().pin().collect()));