+
+
+```
+pub trait Iterator {
+ type Item;
+
+ fn any(&mut self, f: F) -> bool where
+ F: FnMut(Self::Item) -> bool;
+}
+
+fn main() {
+ let vec1 = vec![1, 2, 3];
+ let vec2 = vec![4, 5, 6];
+
+ println!("2 in vec1: {}", vec1.iter() .any(|&x| x == 2));
+ println!("2 in vec2: {}", vec2.into_iter().any(|x| x == 2));
+
+ println!("vec1 len: {}", vec1.len());
+ println!("First element of vec1 is: {}", vec1[0]);
+ // `into_iter()` does move `vec2` and its elements, so they cannot be used again
+
+ let array1 = [1, 2, 3];
+ let array2 = [4, 5, 6];
+
+ println!("2 in array1: {}", array1.iter() .any(|&x| x == 2));
+ println!("2 in array2: {}", array2.into_iter().any(|x| x == 2));
+}
+```
+ |
+
+```
+pub trait Iterator
+ type Item
+
+ fn any(&mut self, f: F) -> bool where
+ F: FnMut(Self::Item) -> bool //! Should we be able to drop the `Self::` here?
+}
+
+fn main
+ let vec1 = vec![1, 2, 3]
+ vec2 = vec![4, 5, 6]
+
+ println! "2 in vec1: {}", vec1.iter() .any(|&x| x == 2));
+ println!("2 in vec2: {}", vec2.into_iter().any(|x| x == 2));
+
+ println!("vec1 len: {}", vec1.len());
+ println!("First element of vec1 is: {}", vec1[0]);
+ // `into_iter()` does move `vec2` and its elements, so they cannot be used again
+
+ let array1 = [1, 2, 3];
+ let array2 = [4, 5, 6];
+
+ println!("2 in array1: {}", array1.iter() .any(|&x| x == 2));
+ println!("2 in array2: {}", array2.into_iter().any(|x| x == 2));
+}
+```
+ |