Skip to content

Commit 5030b35

Browse files
authored
Adds a `main` function to the last impl Trait example that demonstrates the expected behavior.
1 parent 28aca4a commit 5030b35

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/trait/impl_trait.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,10 @@ fn double_positives<'a>(numbers: &'a Vec<i32>) -> impl Iterator<Item = i32> + 'a
6868
.filter(|x| x > &&0)
6969
.map(|x| x * 2)
7070
}
71+
72+
fn main() {
73+
let singles = vec![-3, -2, 2, 3];
74+
let doubles = double_positives(&singles);
75+
assert_eq!(doubles.collect::<Vec<i32>>(), vec![4, 6]);
76+
}
7177
```

0 commit comments

Comments
 (0)