pub fn try_join_all<I>(iter: I) -> TryJoinAll<<I as IntoIterator>::Item> ⓘ
Expand description
Creates a future which represents a collection of the outputs of the futures given.
The returned future will drive execution for all of its underlying futures,
collecting the results into a destination Vec<T>
in the same order as they
were provided.
If any future returns an error then all other futures will be canceled and
an error will be returned immediately. If all futures complete successfully,
however, then the returned future will succeed with a Vec
of all the
successful results.
§Examples
use futures_buffered::try_join_all;
async fn foo(i: u32) -> Result<u32, u32> {
if i < 4 { Ok(i) } else { Err(i) }
}
let futures = vec![foo(1), foo(2), foo(3)];
assert_eq!(try_join_all(futures).await, Ok(vec![1, 2, 3]));
let futures = vec![foo(1), foo(2), foo(3), foo(4)];
assert_eq!(try_join_all(futures).await, Err(4));
See join_all
for benchmark results