Skip to content

Commit e05ebf6

Browse files
committed
---
yaml --- r: 158710 b: refs/heads/snap-stage3 c: 6371879 h: refs/heads/master v: v3
1 parent ae94a98 commit e05ebf6

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 0b48001c28329392b26961eaf1c3ed293a352d6f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 0b5bc3314fa9bf768163828a8e38bac588936fe9
4+
refs/heads/snap-stage3: 63718792df1214d0bf7b5a12508cc7301e3be665
55
refs/heads/try: f58aad6dce273570fb130b4df008ef9acd5a5be2
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/doc/guide.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4601,20 +4601,24 @@ returns `true` or `false`. The new iterator `filter()` produces
46014601
only the elements that that closure returns `true` for:
46024602

46034603
```{rust}
4604-
for i in range(1i, 100i).filter(|x| x % 2 == 0) {
4604+
for i in range(1i, 100i).filter(|&x| x % 2 == 0) {
46054605
println!("{}", i);
46064606
}
46074607
```
46084608

46094609
This will print all of the even numbers between one and a hundred.
4610+
(Note that because `filter` doesn't consume the elements that are
4611+
being iterated over, it is passed a reference to each element, and
4612+
thus the filter predicate uses the `&x` pattern to extract the integer
4613+
itself.)
46104614

46114615
You can chain all three things together: start with an iterator, adapt it
46124616
a few times, and then consume the result. Check it out:
46134617

46144618
```{rust}
46154619
range(1i, 1000i)
4616-
.filter(|x| x % 2 == 0)
4617-
.filter(|x| x % 3 == 0)
4620+
.filter(|&x| x % 2 == 0)
4621+
.filter(|&x| x % 3 == 0)
46184622
.take(5)
46194623
.collect::<Vec<int>>();
46204624
```

0 commit comments

Comments
 (0)