[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:
Matt Brubeck 2015-04-24 09:19:51 -07:00
parent 7972fbb735
commit 331821e3a0

View file

@ -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);
}
```