Skip to content

Commit 8f31377

Browse files
committed
Update for_expr docs.
1 parent 25f3b29 commit 8f31377

File tree

1 file changed

+4
-17
lines changed

1 file changed

+4
-17
lines changed

doc/rust.md

+4-17
Original file line numberDiff line numberDiff line change
@@ -2459,25 +2459,12 @@ do k(3) |j| {
24592459
### For expressions
24602460

24612461
~~~~~~~~{.ebnf .gram}
2462-
for_expr : "for" expr [ '|' ident_list '|' ] ? '{' block '}' ;
2462+
for_expr : "for" pat "in" expr '{' block '}' ;
24632463
~~~~~~~~
24642464

2465-
A _for expression_ is similar to a [`do` expression](#do-expressions),
2466-
in that it provides a special block-form of lambda expression,
2467-
suited to passing the `block` function to a higher-order function implementing a loop.
2468-
2469-
In contrast to a `do` expression, a `for` expression is designed to work
2470-
with methods such as `each` and `times`, that require the body block to
2471-
return a boolean. The `for` expression accommodates this by implicitly
2472-
returning `true` at the end of each block, unless a `break` expression
2473-
is evaluated.
2474-
2475-
In addition, [`break`](#break-expressions) and [`loop`](#loop-expressions) expressions
2476-
are rewritten inside `for` expressions in the same way that `return` expressions are,
2477-
with a combination of local flag variables,
2478-
and early boolean-valued returns from the `block` function,
2479-
such that the meaning of `break` and `loop` is preserved in a primitive loop
2480-
when rewritten as a `for` loop controlled by a higher order function.
2465+
A `for` expression is a syntactic construct for looping
2466+
over elements provided by an implementation of
2467+
`std::iterator::Iterator`.
24812468

24822469
An example of a for loop over the contents of a vector:
24832470

0 commit comments

Comments
 (0)