Function tupleops::all_ok[][src]

pub fn all_ok<Tpl>(tpl: Tpl) -> Result<AllOk<Tpl>, Tpl> where
    Tpl: TupleAllOk<Tpl>, 
This is supported on crate feature all-ok only.
Expand description

Element-wise unwrap a tuple of Results if all elements are good. Return the input otherwise.

use tupleops::all_ok;

fn good(value: i32) -> Result<i32, ()> {
    Ok(value)
}

fn bad(_: i32) -> Result<i32, ()> {
    Err(())
}

assert_eq!(
    all_ok((good(1), good(2), good(3))),
    Ok((1, 2, 3)),
);

assert_eq!(
    all_ok((good(1), bad(2), good(3))),
    Err((Ok(1), Err(()), Ok(3))),
);

assert_eq!(
    all_ok(()),
    Ok(()),
);

See also: AllOk, TupleAllOk.