Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Adds a `main` function to the last impl Trait example that demonstrates the expected behavior.
  • Loading branch information
mautamu authored Sep 30, 2021
1 parent 28aca4a commit 5030b35
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/trait/impl_trait.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,10 @@ fn double_positives<'a>(numbers: &'a Vec<i32>) -> impl Iterator<Item = i32> + 'a
.filter(|x| x > &&0)
.map(|x| x * 2)
}
fn main() {
let singles = vec![-3, -2, 2, 3];
let doubles = double_positives(&singles);
assert_eq!(doubles.collect::<Vec<i32>>(), vec![4, 6]);
}
```

0 comments on commit 5030b35

Please sign in to comment.