Skip to content

Commit 331821e

Browse files
committed
[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.
1 parent 7972fbb commit 331821e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/doc/reference.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -3192,7 +3192,7 @@ for_expr : [ lifetime ':' ] "for" pat "in" no_struct_literal_expr '{' block '}'
31923192
```
31933193

31943194
A `for` expression is a syntactic construct for looping over elements provided
3195-
by an implementation of `std::iter::Iterator`.
3195+
by an implementation of `std::iter::IntoIterator`.
31963196

31973197
An example of a for loop over the contents of an array:
31983198

@@ -3205,8 +3205,8 @@ An example of a for loop over the contents of an array:
32053205
32063206
let v: &[Foo] = &[a, b, c];
32073207
3208-
for e in v.iter() {
3209-
bar(*e);
3208+
for e in v {
3209+
bar(e);
32103210
}
32113211
```
32123212

0 commit comments

Comments
 (0)