error[E0277]: `?` couldn't convert the error to `()` --> $DIR/option-to-result.rs:5:6 | LL | fn test_result() -> Result<(),()> { | ------------- expected `()` because of this LL | let a:Option<()> = Some(()); LL | a?; | ^ the trait `std::convert::From` is not implemented for `()` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = note: required by `std::convert::From::from` help: consider converting the `Option` into a `Result` using `Option::ok_or` or `Option::ok_or_else` | LL | a.ok_or_else(|| /* error value */)?; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: `?` couldn't convert the error to `std::option::NoneError` --> $DIR/option-to-result.rs:11:6 | LL | fn test_option() -> Option{ | ----------- expected `std::option::NoneError` because of this LL | let a:Result = Ok(5); LL | a?; | ^ the trait `std::convert::From` is not implemented for `std::option::NoneError` | = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait = note: required by `std::convert::From::from` help: consider converting the `Result` into an `Option` using `Result::ok` | LL | a.ok()?; | ^^^^^ error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`.