It seems that rustc should provide a better error message or hint when one tries to use the ? operator on an Option in a function returning a Result or vice-versa.
Currently this is the error you get:
error[E0277]: `?` couldn't convert the error to `MyErrorType`
--> src/main.rs:10:19
|
10 | let a = foo(i)?;
| ^ the trait `std::convert::From<std::option::NoneError>` is not implemented for `MyErrorType`
|
= note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait
= note: required by `std::convert::From::from`
However, it would be better to suggest the use of Option::ok_or or Option::ok_or_else, or Result::ok, instead of referencing something dependent on the try_trait feature (NoneError).
This issue has been assigned to @Duddino via this comment.
It seems that
rustcshould provide a better error message or hint when one tries to use the?operator on anOptionin a function returning aResultor vice-versa.Currently this is the error you get:
However, it would be better to suggest the use of
Option::ok_ororOption::ok_or_else, orResult::ok, instead of referencing something dependent on thetry_traitfeature (NoneError).This issue has been assigned to @Duddino via this comment.