Skip to main content

try_join

Function try_join 

Source
pub fn try_join<T1, T2, E, A, B>(a: A, b: B) -> TryJoin<A, B> ⓘ
where A: Future<Output = Result<T1, E>>, B: Future<Output = Result<T2, E>>,
Expand description

Drive two fallible futures concurrently, short-circuiting on the first error.

On the first Err, that error is returned without polling the other future again; otherwise both Ok values are returned once both complete. The unfinished future is dropped with TryJoin. A spawned Task detaches when dropped, so it keeps running; cancel such a task explicitly if it must stop when the other branch fails.