Closed
Description
Playground link: https://play.rust-lang.org/?gist=41596a413b9d567407a84423bd63174a&version=stable&mode=debug
Error:
error[E0308]: mismatched types
--> src/main.rs:7:39
|
1 | fn main() {
| - expected `()` because of default return type
...
7 | thingy(if let Some(r) = opt { r } else { None });
| ^ expected enum `std::option::Option`, found mutable reference
|
= note: expected type `std::option::Option<&mut i32>`
found type `&mut {integer}`
For some reason rustc
appears to include the return type of main
as if it was important here, even though the expression is passing the return value to the thingy
function.