From 87591f4a3d8b29c8cd77b4b2dc9f656e47ba527b Mon Sep 17 00:00:00 2001 From: Alula Date: Sat, 19 Dec 2020 17:29:59 +0100 Subject: [PATCH] add get_weapon_type_mut --- src/inventory.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/inventory.rs b/src/inventory.rs index 38190de..6cfa523 100644 --- a/src/inventory.rs +++ b/src/inventory.rs @@ -110,6 +110,10 @@ impl Inventory { self.weapons.get(idx) } + pub fn get_weapon_type_mut(&mut self, wtype: WeaponType) -> Option<&mut Weapon> { + self.weapons.iter_mut().find(|weapon| weapon.wtype == wtype) + } + pub fn get_current_weapon(&self) -> Option<&Weapon> { self.weapons.get(self.current_weapon as usize) }