async_macros

Macro join

Source
macro_rules! join {
    ($($fut:ident),* $(,)?) => { ... };
}
Expand description

Awaits multiple futures simultaneously, returning all results once complete.

While join!(a, b) is similar to (a.await, b.await), join! polls both futures concurrently and therefore is more efficent.

This macro is only usable inside of async functions, closures, and blocks.

ยงExamples

#![feature(async_await)]
use async_macros::join;
use futures::future;

let a = future::ready(1u8);
let b = future::ready(2u8);

assert_eq!(join!(a, b).await, (1, 2));