[reference] Update 7.2.20: For expressions.
* `for` loops now use `IntoIterator` instead of just `Iterator` * Simplify the example by removing unnecessary `Vec::iter` call.
This commit is contained in:
parent
7972fbb735
commit
331821e3a0
1 changed files with 3 additions and 3 deletions
|
@ -3192,7 +3192,7 @@ for_expr : [ lifetime ':' ] "for" pat "in" no_struct_literal_expr '{' block '}'
|
|||
```
|
||||
|
||||
A `for` expression is a syntactic construct for looping over elements provided
|
||||
by an implementation of `std::iter::Iterator`.
|
||||
by an implementation of `std::iter::IntoIterator`.
|
||||
|
||||
An example of a for loop over the contents of an array:
|
||||
|
||||
|
@ -3205,8 +3205,8 @@ An example of a for loop over the contents of an array:
|
|||
|
||||
let v: &[Foo] = &[a, b, c];
|
||||
|
||||
for e in v.iter() {
|
||||
bar(*e);
|
||||
for e in v {
|
||||
bar(e);
|
||||
}
|
||||
```
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue