Why does Rust allow this:
fn main() {
let f = |x: bool| {
async {
return
}
};
}
But not this? Specifically, the error complains that the branches return different types, when they appear to be exactly the same.
fn main() {
let f = |x: bool| {
if true {
async {
return
}
} else {
async {
return
}
}
};
}
error[E0308]: `if` and `else` have incompatible types
--> src/main.rs:42:13
|
37 | / if true {
38 | | async {
| _|_____________-
39 | | | return
40 | | | }
| |_|_____________- expected because of this
41 | | } else {
42 | / | async {
43 | | | return
44 | | | }
| |_|_____________^ expected `async` block, found a different `async` block
45 | | }
| |_________- `if` and `else` have incompatible types
|