Macro join

macro join( $($fut:expr),+ $(,)? ) {
    ...
}

Polls multiple futures simultaneously, returning a tuple of all results once complete.

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

Examples

#![feature(future_join)]

use std::future::join;

async fn one() -> usize { 1 }
async fn two() -> usize { 2 }

# let _ =  async {
let x = join!(one(), two()).await;
assert_eq!(x, (1, 2));
# };

join! is variadic, so you can pass any number of futures:

#![feature(future_join)]

use std::future::join;

async fn one() -> usize { 1 }
async fn two() -> usize { 2 }
async fn three() -> usize { 3 }

# let _ = async {
let x = join!(one(), two(), three()).await;
assert_eq!(x, (1, 2, 3));
# };