#[derive(PartialEq, Debug)] struct Shoe { size: u32, style: String, } fn shoes_in_my_size(shoe: Vec, shoe_size: u32) -> Vec { shoe.into_iter() .filter(|s| s.size == shoe_size) .collect() } #[test] fn filters_by_size() { let shoes = vec![ Shoe {size: 10, style: String::from("sneaker")}, Shoe {size: 13, style: String::from("sandal")}, Shoe {size: 10, style: String::from("boot")}, ]; let in_my_size = shoes_in_my_size(shoes, 10); assert_eq!(in_my_size, vec![ Shoe {size: 10, style: String::from("sneaker")}, Shoe {size: 10, style: String::from("boo")}, ]); } fn main() { let shoes = vec![ Shoe {size: 10, style: String::from("sneaker")}, Shoe {size: 13, style: String::from("sandal")}, Shoe {size: 10, style: String::from("boot")}, ]; shoes_in_my_size(shoes, 10); }