Macro zng::task::all

source ·
macro_rules! all {
    ($fut0:expr $(,)?) => { ... };
    ($fut0:expr, $fut1:expr $(,)?) => { ... };
    ($fut0:expr, $fut1:expr, $fut2:expr $(,)?) => { ... };
    ($fut0:expr, $fut1:expr, $fut2:expr, $fut3:expr $(,)?) => { ... };
    ($fut0:expr, $fut1:expr, $fut2:expr, $fut3:expr, $fut4:expr $(,)?) => { ... };
    ($fut0:expr, $fut1:expr, $fut2:expr, $fut3:expr, $fut4:expr, $fut5:expr $(,)?) => { ... };
    ($fut0:expr, $fut1:expr, $fut2:expr, $fut3:expr, $fut4:expr, $fut5:expr, $fut6:expr $(,)?) => { ... };
    ($fut0:expr, $fut1:expr, $fut2:expr, $fut3:expr, $fut4:expr, $fut5:expr, $fut6:expr, $fut7:expr $(,)?) => { ... };
    ($($fut:expr),+ $(,)?) => { ... };
}
Expand description

A future that zips other futures.

The macro input is a comma separated list of future expressions. The macro output is a future that when “.awaited” produces a tuple of results in the same order as the inputs.

At least one input future is required and any number of futures is accepted. For more than eight futures a proc-macro is used which may cause code auto-complete to stop working in some IDEs.

§Examples

Await for three different futures to complete:

use zng_task as task;

let (a, b, c) = task::all!(
    task::run(async { 'a' }),
    task::wait(|| "b"),
    async { b"c" }
).await;