Skip to content

Commit 9ea36a3

Browse files
authored
Merge pull request #1262 from matklad/patch-2
Clarify reference on async blocks
2 parents f62e93c + 4c94e39 commit 9ea36a3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/expressions/block-expr.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ Async contexts are established by async blocks as well as the bodies of async fu
103103
104104
Async blocks act like a function boundary, much like closures.
105105
Therefore, the `?` operator and `return` expressions both affect the output of the future, not the enclosing function or other context.
106-
That is, `return <expr>` from within a closure will return the result of `<expr>` as the output of the future.
106+
That is, `return <expr>` from within an async block will return the result of `<expr>` as the output of the future.
107107
Similarly, if `<expr>?` propagates an error, that error is propagated as the result of the future.
108108
109109
Finally, the `break` and `continue` keywords cannot be used to branch out from an async block.
@@ -112,7 +112,7 @@ Therefore the following is illegal:
112112
```rust,compile_fail
113113
loop {
114114
async move {
115-
break; // This would break out of the loop.
115+
break; // error[E0267]: `break` inside of an `async` block
116116
}
117117
}
118118
```

0 commit comments

Comments
 (0)