-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
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.
ChayimFriedman2steffahn
Metadata
Metadata
Assignees
Labels
A-async-awaitArea: Async & AwaitArea: Async & AwaitA-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsArea: Documentation for any part of the project, including the compiler, standard library, and toolsE-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
Lynnesbian commentedon Apr 10, 2025
I'd be interested in claiming this as my first issue.
This behaviour is documented in the Async Rust Book as of this commit.
The current docs for the
async
keyword are fairly minimal, so I'm not sure how much they should be expanded, but so far I've come up with something like this, adding to the existing comment:@rustbot claim
async
block behaviour #139608Rollup merge of rust-lang#139608 - Lynnesbian:improve-async-block-doc…
Rollup merge of rust-lang#139608 - Lynnesbian:improve-async-block-doc…
Unrolled build for rust-lang#139608
Rollup merge of rust-lang#139608 - Lynnesbian:improve-async-block-doc…
clubby789 commentedon May 13, 2025
Seems like this is well documented as of #139608, closing