[][src]Function smol::future::try_zip

pub fn try_zip<T1, T2, E, F1, F2>(future1: F1, future2: F2) -> TryZip<F1, F2>

Notable traits for TryZip<F1, F2>

impl<T1, T2, E, F1, F2> Future for TryZip<F1, F2> where
    F1: Future<Output = Result<T1, E>>,
    F2: Future<Output = Result<T2, E>>, 
type Output = Result<(T1, T2), E>;
where
    F1: Future<Output = Result<T1, E>>,
    F2: Future<Output = Result<T2, E>>, 

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));