diff options
| author | Jake Goulding <jake.goulding@gmail.com> | 2015-12-02 14:15:46 -0500 |
|---|---|---|
| committer | Jake Goulding <jake.goulding@gmail.com> | 2015-12-02 14:48:10 -0500 |
| commit | 06e4b709c389c674e55326f50faf7ac308abe8c1 (patch) | |
| tree | 14103373ebaf3bae81b7264135815219e2087850 | |
| parent | 88397e092e01b6043b6f65772710dfe0e59056c5 (diff) | |
| download | rust-06e4b709c389c674e55326f50faf7ac308abe8c1.tar.gz rust-06e4b709c389c674e55326f50faf7ac308abe8c1.zip | |
Clarify that a for loop uses `IntoIterator`
| -rw-r--r-- | src/doc/book/loops.md | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/doc/book/loops.md b/src/doc/book/loops.md index 72e803d04f8..3e12e86da23 100644 --- a/src/doc/book/loops.md +++ b/src/doc/book/loops.md @@ -80,13 +80,15 @@ for var in expression { } ``` -The expression is an [iterator][iterator]. The iterator gives back a series of -elements. Each element is one iteration of the loop. That value is then bound -to the name `var`, which is valid for the loop body. Once the body is over, the -next value is fetched from the iterator, and we loop another time. When there -are no more values, the `for` loop is over. +The expression is an item can can be converted into an [iterator] using +[`IntoIterator`]. The iterator gives back a series of elements. Each element is +one iteration of the loop. That value is then bound to the name `var`, which is +valid for the loop body. Once the body is over, the next value is fetched from +the iterator, and we loop another time. When there are no more values, the `for` +loop is over. [iterator]: iterators.html +[`IntoIterator`]: ../std/iter/trait.IntoIterator.html In our example, `0..10` is an expression that takes a start and an end position, and gives an iterator over those values. The upper bound is exclusive, though, |
