From 3524f382405aafe53aa0e551d3e8345052a76289 Mon Sep 17 00:00:00 2001 From: Andy Newjack Date: Sat, 23 May 2020 01:16:02 -0300 Subject: [PATCH] dont unwrap --- src/entity/item/mod.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/entity/item/mod.rs b/src/entity/item/mod.rs index a4a6183..be29d74 100644 --- a/src/entity/item/mod.rs +++ b/src/entity/item/mod.rs @@ -118,15 +118,15 @@ impl ItemDetail { .or(shield::ShieldType::parse_type([data[0],data[1],data[2]]).map(|s| ItemType::Shield(s))) .or(unit::UnitType::parse_type([data[0],data[1],data[2]]).map(|u| ItemType::Unit(u))) .or(mag::MagType::parse_type([data[0],data[1],data[2]]).map(|m| ItemType::Mag(m))) - .or(tool::ToolType::parse_type([data[0],data[1],data[2]]).map(|t| ItemType::Tool(t))).unwrap(); + .or(tool::ToolType::parse_type([data[0],data[1],data[2]]).map(|t| ItemType::Tool(t))).ok()?; match item_type { - ItemType::Weapon(_w) => Some(ItemDropType::Weapon(weapon::Weapon::from_bytes(data).unwrap())), - ItemType::Armor(_a) => Some(ItemDropType::Armor(armor::Armor::from_bytes(data).unwrap())), - ItemType::Shield(_s) => Some(ItemDropType::Shield(shield::Shield::from_bytes(data).unwrap())), - ItemType::Unit(_u) => Some(ItemDropType::Unit(unit::Unit::from_bytes(data).unwrap())), - ItemType::Mag(_m) => Some(ItemDropType::Mag(mag::Mag::from_bytes(data).unwrap())), - ItemType::Tool(_t) => Some(ItemDropType::Tool(tool::Tool::from_bytes(data).unwrap())), + ItemType::Weapon(_w) => Some(ItemDropType::Weapon(weapon::Weapon::from_bytes(data).ok()?)), + ItemType::Armor(_a) => Some(ItemDropType::Armor(armor::Armor::from_bytes(data).ok()?)), + ItemType::Shield(_s) => Some(ItemDropType::Shield(shield::Shield::from_bytes(data).ok()?)), + ItemType::Unit(_u) => Some(ItemDropType::Unit(unit::Unit::from_bytes(data).ok()?)), + ItemType::Mag(_m) => Some(ItemDropType::Mag(mag::Mag::from_bytes(data).ok()?)), + ItemType::Tool(_t) => Some(ItemDropType::Tool(tool::Tool::from_bytes(data).ok()?)), _ => None, } }