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)?;