Skip to main content

try_join_all

Function try_join_all 

Source
pub async fn try_join_all<I, F, T>(futures: I) -> Result<Vec<T>, OperationError>
where I: IntoIterator<Item = F>, F: Future<Output = Result<T, OperationError>>,
Expand description

Run a collection of futures concurrently and collect their results.

All futures start executing immediately. Returns a Vec<T> in the same order as the input iterator, or the first OperationError encountered (remaining futures are dropped on error).

§Examples

use ironflow_core::prelude::*;

let outputs = try_join_all(vec![
    Shell::new("echo one").run(),
    Shell::new("echo two").run(),
    Shell::new("echo three").run(),
]).await?;

assert_eq!(outputs.len(), 3);

§Errors

Returns the first OperationError produced by any future. When an error occurs, all other in-flight futures are cancelled.