Skip to content

Commit a2f58f3

Browse files
committed
Auto merge of #30169 - shepmaster:for-loop-into-iterator, r=steveklabnik
2 parents e4066f5 + 06e4b70 commit a2f58f3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/doc/book/loops.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,15 @@ for var in expression {
8080
}
8181
```
8282

83-
The expression is an [iterator][iterator]. The iterator gives back a series of
84-
elements. Each element is one iteration of the loop. That value is then bound
85-
to the name `var`, which is valid for the loop body. Once the body is over, the
86-
next value is fetched from the iterator, and we loop another time. When there
87-
are no more values, the `for` loop is over.
83+
The expression is an item can can be converted into an [iterator] using
84+
[`IntoIterator`]. The iterator gives back a series of elements. Each element is
85+
one iteration of the loop. That value is then bound to the name `var`, which is
86+
valid for the loop body. Once the body is over, the next value is fetched from
87+
the iterator, and we loop another time. When there are no more values, the `for`
88+
loop is over.
8889

8990
[iterator]: iterators.html
91+
[`IntoIterator`]: ../std/iter/trait.IntoIterator.html
9092

9193
In our example, `0..10` is an expression that takes a start and an end position,
9294
and gives an iterator over those values. The upper bound is exclusive, though,

0 commit comments

Comments
 (0)