From 5a39e24beb4b90fe17ce7b698ad353eb16d974df Mon Sep 17 00:00:00 2001 From: Brad Clawsie Date: Thu, 12 Nov 2026 11:49:07 -0600 Subject: fix: corrections_2 --- learn_1/src/main.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'learn_1/src/main.rs') diff --git a/learn_1/src/main.rs b/learn_1/src/main.rs index 80d8985..0d8181f 100644 --- a/learn_1/src/main.rs +++ b/learn_1/src/main.rs @@ -15,7 +15,7 @@ impl Inventory { // `contains` returns true if `item` is in `self.items`. pub fn contains(&self, item: &str) -> bool { - self.items.contains(&String::from(item)) + self.items.iter().any(|x| x == item) } // `remove` removes `item` from `self.items` if present. @@ -41,8 +41,7 @@ mod tests { #[test] fn test_new() { let inventory = Inventory::new(); - let _ = inventory.items; - assert_eq!(true, true); + assert_eq!(inventory.items.len(), 0 as usize); } #[test] -- cgit v1.2.3