Skip to content

Commit 2da35f0

Browse files
committed
---
yaml --- r: 187566 b: refs/heads/tmp c: 9f2b067 h: refs/heads/master v: v3
1 parent 6023bf0 commit 2da35f0

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 522d09dfecbeca1595f25ac58c6d0178bbd21d7d
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: 72eaf2c30e846b3d14c520c0c7638b2b16bf8c73
37+
refs/heads/tmp: 9f2b0671f88b2cc6bb73575db47d265dbb246e34
3838
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/tmp/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)