Skip to content

Commit 06ea989

Browse files
Sawyer47alexcrichton
authored andcommitted
doc: updates rust manual (loop to continue)
Keyword for continue expressions was changed from loop to continue, but the manual was not updated.
1 parent 31de69d commit 06ea989

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

src/doc/rust.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ The keywords are the following strings:
208208
~~~~ {.notrust .keyword}
209209
as
210210
box break
211-
crate
211+
continue crate
212212
else enum extern
213213
false fn for
214214
if impl in
@@ -2924,18 +2924,16 @@ while i < 10 {
29242924

29252925
### Infinite loops
29262926

2927-
The keyword `loop` in Rust appears both in _loop expressions_ and in _continue expressions_.
2928-
A loop expression denotes an infinite loop;
2929-
see [Continue expressions](#continue-expressions) for continue expressions.
2927+
A `loop` expression denotes an infinite loop.
29302928

29312929
~~~~ {.notrust .ebnf .gram}
29322930
loop_expr : [ lifetime ':' ] "loop" '{' block '}';
29332931
~~~~
29342932

29352933
A `loop` expression may optionally have a _label_.
29362934
If a label is present,
2937-
then labeled `break` and `loop` expressions nested within this loop may exit out of this loop or return control to its head.
2938-
See [Break expressions](#break-expressions).
2935+
then labeled `break` and `continue` expressions nested within this loop may exit out of this loop or return control to its head.
2936+
See [Break expressions](#break-expressions) and [Continue expressions](#continue-expressions).
29392937

29402938
### Break expressions
29412939

@@ -2953,21 +2951,21 @@ but must enclose it.
29532951
### Continue expressions
29542952

29552953
~~~~ {.notrust .ebnf .gram}
2956-
continue_expr : "loop" [ lifetime ];
2954+
continue_expr : "continue" [ lifetime ];
29572955
~~~~
29582956

2959-
A continue expression, written `loop`, also has an optional `label`.
2957+
A `continue` expression has an optional `label`.
29602958
If the label is absent,
2961-
then executing a `loop` expression immediately terminates the current iteration of the innermost loop enclosing it,
2959+
then executing a `continue` expression immediately terminates the current iteration of the innermost loop enclosing it,
29622960
returning control to the loop *head*.
29632961
In the case of a `while` loop,
29642962
the head is the conditional expression controlling the loop.
29652963
In the case of a `for` loop, the head is the call-expression controlling the loop.
2966-
If the label is present, then `loop foo` returns control to the head of the loop with label `foo`,
2964+
If the label is present, then `continue foo` returns control to the head of the loop with label `foo`,
29672965
which need not be the innermost label enclosing the `break` expression,
29682966
but must enclose it.
29692967

2970-
A `loop` expression is only permitted in the body of a loop.
2968+
A `continue` expression is only permitted in the body of a loop.
29712969

29722970
### For expressions
29732971

0 commit comments

Comments
 (0)