Skip to content

Semantics of control flow operators (return, continue, ?) in async blocks is severely underdocumented  #101444

Closed
@matklad

Description

@matklad

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

didn't show up any example of the syntax.

This is documented in the reference (rust-lang/reference#1262), but without an example.

Metadata

Metadata

Assignees

Labels

A-async-awaitArea: Async & AwaitA-docsArea: 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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions