Yeah, Rust does that as well. The issue the author is talking about here is that when you write a closure:
fn foo(inputs: &[Input]) -> Result<Vec<Output>, Error> {
inputs
.iter()
.map(|input| { input.something_fallible()? })
.collect()
}
that ? is an early return from the closure, not foo. The correct way to do this is: fn foo(inputs: &[Input]) -> Result<Vec<Output>, Error> {
inputs
.iter()
.map(|input| { input.something_fallible() })
.collect::<Result<Vec<Output>, Error>>()
}
ref: https://play.rust-lang.org/?version=stable&mode=debug&editio...