macro_rules! stream { ($($tt:tt)*) => { ... }; }
Expand description
Asynchronous stream
See crate documentation for more details.
ยงExamples
use async_stream::stream;
use futures_util::pin_mut;
use futures_util::stream::StreamExt;
#[tokio::main]
async fn main() {
let s = stream! {
for i in 0..3 {
yield i;
}
};
pin_mut!(s); // needed for iteration
while let Some(value) = s.next().await {
println!("got {}", value);
}
}