This simple code (playground):
#[tokio::main]
async fn main() {
let f: futures::future::OptionFuture<()> = None.into();
let () = f.await;
}
produces:
error[E0277]: `()` is not a future
--> src/main.rs:4:15
|
4 | let () = f.await;
| ^^^^^^ `()` is not a future
|
= help: the trait `futures::Future` is not implemented for `()`
= note: () must be a future or must implement `IntoFuture` to be awaited
= note: required because of the requirements on the impl of `futures::Future` for `OptionFuture<()>`
= note: required because of the requirements on the impl of `std::future::IntoFuture` for `OptionFuture<()>`
help: remove the `.await`
|
4 - let () = f.await;
4 + let () = f;
But f
has type OptionFuture<()>
, not ()
, and OptionFuture
is Future
!