Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ca921e6

Browse files
committedMar 19, 2023
Improve labeled blocks documentation
* list labeled blocks in the namespaces page * add an example * improve wording
1 parent ebab1cd commit ca921e6

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed
 

‎src/expressions/loop-expr.md

+10-2
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,16 @@ A `break` expression is only permitted in the body of a loop, and has one of the
249249
>    [_BlockExpression_]
250250
251251
Labelled block expressions are exactly like block expressions, except that they allow using `break` expressions within the block.
252-
Unlike other loops, `break` expressions within a label expression *must* have a label (i.e. the label is not optional).
253-
Unlike other loops, labelled block expressions *must* begin with a label.
252+
Unlike with loops, `break` expressions within a labelled block expression *must* have a label (i.e. the label is not optional).
253+
Unlike loops, labelled block expressions *must* begin with a label.
254+
255+
```rust
256+
'a: {
257+
loop {
258+
break 'a;
259+
}
260+
}
261+
```
254262

255263
## `continue` expressions
256264

‎src/names/namespaces.md

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ The following is a list of namespaces, with their corresponding entities:
5252
* [Generic lifetime parameters]
5353
* Label Namespace
5454
* [Loop labels]
55+
* [Block labels]
5556

5657
An example of how overlapping names in different namespaces can be used unambiguously:
5758

@@ -132,6 +133,7 @@ It is still an error for a [`use` import] to shadow another macro, regardless of
132133
[Attribute macros]: ../procedural-macros.md#attribute-macros
133134
[attributes]: ../attributes.md
134135
[bang-style macros]: ../macros.md
136+
[Block labels]: ../expressions/loop-expr.md#labelled-block-expressions
135137
[boolean]: ../types/boolean.md
136138
[Built-in attributes]: ../attributes.md#built-in-attributes-index
137139
[closure parameters]: ../expressions/closure-expr.md

0 commit comments

Comments
 (0)
Please sign in to comment.