Closed
Description
As a novice Rust programmer, I was quite surprised that the following works:
#[tokio::main]
async fn main() {
let f = async { return 92 };
assert_eq!(f.await, 92);
}
I don't remeber reading that in any kind of docs, and looking at the
- async book https://rust-lang.github.io/async-book/01_getting_started/04_async_await_primer.html
- async keyword https://doc.rust-lang.org/stable/std/keyword.async.html
- return keyword https://doc.rust-lang.org/stable/std/keyword.return.html
didn't show up any example of the syntax.
This is documented in the reference (rust-lang/reference#1262), but without an example.