Skip to content

Commit 9f2b067

Browse files
committed
Fixed erroneous statements in iterators.md.
1 parent 72eaf2c commit 9f2b067

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/doc/trpl/iterators.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ for num in &nums {
9191
```
9292

9393
Now we're explicitly dereferencing `num`. Why does `&nums` give us
94-
references? Because we asked it to with `&`. If we had not had the
95-
`&`, `nums` would have been moved into the `for` loop and consumed,
96-
and we we would no longer be able to access `nums` afterward. With
97-
references, we're just borrowing a reference to the data, and so it's
98-
just passing a reference, without needing to do the move.
94+
references? Firstly, because we explicitly asked it to with
95+
`&`. Secondly, if it gave us the data itself, we would have to be its
96+
owner, which would involve making a copy of the data and giving us the
97+
copy. With references, we're just borrowing a reference to the data,
98+
and so it's just passing a reference, without needing to do the move.
9999

100100
So, now that we've established that ranges are often not what you want, let's
101101
talk about what you do want instead.
@@ -242,9 +242,6 @@ for num in nums.iter() {
242242
}
243243
```
244244

245-
Sometimes you need this functionality, but since for loops operate on the
246-
`IntoIterator` trait, calling `.iter()` is rarely necessary.
247-
248245
These two basic iterators should serve you well. There are some more
249246
advanced iterators, including ones that are infinite. Like `count`:
250247

0 commit comments

Comments
 (0)