Re:Announcing Rust 1.13
by masklinn on Thursday November 10, 2016 @04:36PM
(#12924633)
> So do all the functions have to have the same error type as the function that is calling them?
Not quite, they must have an error type convertible to the caller's error type, try! (and ?) really desugar to
match val {
Ok(v) => v,
Err(e) => return Err(From::from(e))
}
From is a generic conversion trait, a type A can implement From<B> in which case `From::from(b: B)` will yield an A (assuming A is either inferred or explicitly requested)
Not quite, they must have an error type convertible to the caller's error type, try! (and ?) really desugar to
From is a generic conversion trait, a type A can implement From<B> in which case `From::from(b: B)` will yield an A (assuming A is either inferred or explicitly requested)