From c437c3da5b5549f5465ca7dd61d0d1188e5d1e62 Mon Sep 17 00:00:00 2001 From: jake Date: Wed, 2 Dec 2020 22:51:36 -0700 Subject: [PATCH] split this into individual/individual_mut --- src/ship/items/inventory.rs | 9 ++++++++- src/ship/items/manager.rs | 2 +- src/ship/items/use_tool.rs | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ship/items/inventory.rs b/src/ship/items/inventory.rs index 68be036..7c45b9e 100644 --- a/src/ship/items/inventory.rs +++ b/src/ship/items/inventory.rs @@ -198,7 +198,14 @@ impl InventoryItem { Ok(()) } - pub fn individual(&mut self) -> Option<&mut IndividualInventoryItem> { + pub fn individual(&self) -> Option<&IndividualInventoryItem> { + match self { + InventoryItem::Individual(ref individual_inventory_item) => Some(individual_inventory_item), + _ => None + } + } + + pub fn individual_mut(&mut self) -> Option<&mut IndividualInventoryItem> { match self { InventoryItem::Individual(ref mut individual_inventory_item) => Some(individual_inventory_item), _ => None diff --git a/src/ship/items/manager.rs b/src/ship/items/manager.rs index f3986f7..d8aac3d 100644 --- a/src/ship/items/manager.rs +++ b/src/ship/items/manager.rs @@ -611,7 +611,7 @@ impl ItemManager { let individual_item = mag_handle.item_mut() .ok_or(ItemManagerError::NoSuchItemId(mag_id))? - .individual() + .individual_mut() .ok_or(ItemManagerError::WrongItemType(mag_id))?; let mag = individual_item .mag_mut() diff --git a/src/ship/items/use_tool.rs b/src/ship/items/use_tool.rs index 671ca53..6440b84 100644 --- a/src/ship/items/use_tool.rs +++ b/src/ship/items/use_tool.rs @@ -52,7 +52,7 @@ async fn mag_cell(entity_gateway: &mut EG, used_cell: &Consum let mag_item = mag_handle.item_mut() .ok_or(UseItemError::InvalidItem)?; let actual_mag = mag_item - .individual() + .individual_mut() .ok_or(UseItemError::InvalidItem)? .mag_mut() .ok_or(UseItemError::InvalidItem)?;