When trying to compile this playground snippet I am getting the following error:
Compiling playground v0.0.1 (/playground)
error[E0308]: `if` and `else` have incompatible types
--> src/main.rs:13:9
|
10 | / if b {
11 | | bar().map(|v| v + 1)
| | -------------------- expected because of this
12 | | } else {
13 | | Box::pin(async { 0u32 })
| | ^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `futures_util::future::future::map::Map`, found struct `std::pin::Pin`
14 | | }
| |_____- `if` and `else` have incompatible types
|
= note: expected type `futures_util::future::future::map::Map<std::pin::Pin<std::boxed::Box<dyn core::future::future::Future<Output = u32> + std::marker::Send>>, [closure@src/main.rs:11:19: 11:28]>`
found struct `std::pin::Pin<std::boxed::Box<impl core::future::future::Future>>`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.
error: could not compile `playground`.
To learn more, run the command again with --verbose.
Why can't the compiler infer that both return values implement the Future trait?