futures_lite::future

Function try_zip

Source
pub fn try_zip<T1, T2, E, F1, F2>(future1: F1, future2: F2) -> TryZip<F1, F2> 
where F1: Future<Output = Result<T1, E>>, F2: Future<Output = Result<T2, E>>,
Expand description

Joins two fallible futures, waiting for both to complete or one of them to error.

§Examples

use futures_lite::future;

let a = async { Ok::<i32, i32>(1) };
let b = async { Err::<i32, i32>(2) };

assert_eq!(future::try_zip(a, b).await, Err(2));