From 5030b355ddd55754a639e323b832e91282f85f2d Mon Sep 17 00:00:00 2001 From: mautamu Date: Wed, 29 Sep 2021 19:07:27 -0500 Subject: [PATCH] Close #1464 Adds a `main` function to the last impl Trait example that demonstrates the expected behavior. --- src/trait/impl_trait.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/trait/impl_trait.md b/src/trait/impl_trait.md index 7b87bd2e9c..f429d9adf7 100644 --- a/src/trait/impl_trait.md +++ b/src/trait/impl_trait.md @@ -68,4 +68,10 @@ fn double_positives<'a>(numbers: &'a Vec) -> impl Iterator + '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![4, 6]); +} ```