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. Useful for “run these two halves until one of them fails, then tear both down”: the unfinished half is cancelled when the caller drops the TryJoin, which is what dropping this future on the spot amounts to.