Skip to content

Commit a62d5be

Browse files
mbrubeckmdinger
authored andcommitted
[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 5e8e657 commit a62d5be

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/doc/reference.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2897,7 +2897,7 @@ loops](#infinite-loops), [break expressions](#break-expressions), and
28972897
### For expressions
28982898

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

29022902
An example of a for loop over the contents of an array:
29032903

@@ -2910,8 +2910,8 @@ An example of a for loop over the contents of an array:
29102910
29112911
let v: &[Foo] = &[a, b, c];
29122912
2913-
for e in v.iter() {
2914-
bar(*e);
2913+
for e in v {
2914+
bar(e);
29152915
}
29162916
```
29172917

0 commit comments

Comments
 (0)