From ca44dcf689d155a02a25b1792feceb52fa2d72eb Mon Sep 17 00:00:00 2001 From: andy Date: Mon, 16 Aug 2021 00:57:23 +0000 Subject: [PATCH] andy vs. clippy round 5 --- src/ship/items/inventory.rs | 2 +- src/ship/items/manager.rs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/ship/items/inventory.rs b/src/ship/items/inventory.rs index 9b175f7..4543e46 100644 --- a/src/ship/items/inventory.rs +++ b/src/ship/items/inventory.rs @@ -1002,7 +1002,7 @@ impl CharacterInventory { pub fn get_item_by_entity_id(&self, item_id: ItemEntityId) -> Option<&InventoryItem> { for item in &self.items { - if let Some(_) = item.entity_ids().iter().find(|&&item| item == item_id) { + if item.entity_ids().iter().any(|&item| item == item_id) { return Some(item) } } diff --git a/src/ship/items/manager.rs b/src/ship/items/manager.rs index 5f4e432..566e8f7 100644 --- a/src/ship/items/manager.rs +++ b/src/ship/items/manager.rs @@ -1396,9 +1396,8 @@ impl ItemAction for TradeMeseta { weapon.increment_kill_counter(); } - for units in equipped_items.unit { - if let Some(unit_entity) = units { - let unit_id = inventory.get_item_by_entity_id(unit_entity).ok_or(ItemManagerError::EntityIdNotInInventory(unit_entity))?.item_id(); + for units in equipped_items.unit.iter().flatten() { + let unit_id = inventory.get_item_by_entity_id(*units).ok_or(ItemManagerError::EntityIdNotInInventory(*units))?.item_id(); let mut unit_handle = inventory.get_item_handle_by_id(unit_id).ok_or(ItemManagerError::NoSuchItemId(unit_id))?; let individual_item_u = unit_handle.item_mut() .ok_or(ItemManagerError::NoSuchItemId(unit_id))? @@ -1409,7 +1408,6 @@ impl ItemAction for TradeMeseta { .ok_or(ItemManagerError::WrongItemType(unit_id))?; unit.increment_kill_counter(); - } } entity_gateway.set_character_inventory(&character.id, &inventory.as_inventory_entity(&character.id)).await?; Ok(())