-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Semantics of control flow operators (return, continue, ?
) in async blocks is severely underdocumented
#101444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
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
#[expect(unused_variables)]
fn example() -> i32 {
let x = {
return 5;
};
}
async fn example() -> i32 {
let x = async {
return 5;
};
x.await
}
@rustbot claim |
…s, r=ibraheemdev Clarify `async` block behaviour Adds some documentation for control flow behaviour pertaining to `return` and `?` within `async` blocks. Fixes (or at least improves) rust-lang#101444. r? rust-lang/docs
…s, r=ibraheemdev Clarify `async` block behaviour Adds some documentation for control flow behaviour pertaining to `return` and `?` within `async` blocks. Fixes (or at least improves) rust-lang#101444. r? rust-lang/docs
Rollup merge of rust-lang#139608 - Lynnesbian:improve-async-block-docs, r=ibraheemdev Clarify `async` block behaviour Adds some documentation for control flow behaviour pertaining to `return` and `?` within `async` blocks. Fixes (or at least improves) rust-lang#101444. r? rust-lang/docs
…s, r=ibraheemdev Clarify `async` block behaviour Adds some documentation for control flow behaviour pertaining to `return` and `?` within `async` blocks. Fixes (or at least improves) rust-lang#101444. r? rust-lang/docs
Seems like this is well documented as of #139608, closing |
As a novice Rust programmer, I was quite surprised that the following works:
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.
The text was updated successfully, but these errors were encountered: