Suppose you have two functions
fn f() -> Result<A, E>
fn g() -> Result<B, E>
Then you can write fn h() -> Result<(A,B), E> {
let x = f()?;
let y = g()?;
Ok((x, y))
}
rather than having to do something like fn h() -> Result<(A,B), E> {
match f() {
Ok(x) => {
match g() {
Ok(y) => Ok((x,y)),
Err(e) => Err(e)
}
},
Err(e) => Err(e),
}
}
(written from memory, please excuse syntax errors)What's new is that this also works with Option<A> now.