pub fn join_array<Fut: Future, const N: usize>(
    futures: [Fut; N]
) -> JoinArray<Fut, N> 
Expand description

合并一个future数组中所有future的结果,等待他们都完成

本函数将以await的方式等待所有future都完成,并返回一个新的future 返回的future会以所有future的结果所组成的元组的方式进行输出。

注意,该函数会消耗传递的future,并会返回一个对其进行了封装的版本。


Joins the result of an array of futures, waiting for them all to complete.

This function will return a new future which awaits all futures to complete. The returned future will finish with a tuple of all results.

Note that this function consumes the passed futures and returns a wrapped version of it.

Examples


async fn foo(n: u32) -> u32 { n }
let a = foo(1);
let b = foo(2);
let c = foo(3);
let res = embassy_futures::join::join_array([a, b, c]).await;

assert_eq!(res, [1, 2, 3]);