diff options
| author | troido <troido@protonmail.com> | 2020-04-06 21:06:17 +0200 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-04-06 21:06:17 +0200 |
| commit | 36034d79acde5039601a0fdf2f9c5e19b5f91003 (patch) | |
| tree | 16ac4e2da49f799fe373908842ff1b953329cd14 /src | |
| parent | 289a342917e9291895b0332dd4ab412b15a7fabf (diff) | |
minor refactoring with cargo clippy
Diffstat (limited to 'src')
| -rw-r--r-- | src/components/ear.rs | 2 | ||||
| -rw-r--r-- | src/controls.rs | 2 | ||||
| -rw-r--r-- | src/item.rs | 4 | ||||
| -rw-r--r-- | src/playerstate.rs | 2 | ||||
| -rw-r--r-- | src/template.rs | 2 | ||||
| -rw-r--r-- | src/world.rs | 2 |
6 files changed, 7 insertions, 7 deletions
diff --git a/src/components/ear.rs b/src/components/ear.rs index d032122..4bfc87b 100644 --- a/src/components/ear.rs +++ b/src/components/ear.rs @@ -13,7 +13,7 @@ pub struct Sound { impl Sound { pub fn as_message(self) -> (Option<String>, String) { - return (None, format!("{}: {}", self.source.unwrap_or("".to_string()), self.text)); + (None, format!("{}: {}", self.source.unwrap_or("".to_string()), self.text)) } } diff --git a/src/controls.rs b/src/controls.rs index 7ed8374..8a10824 100644 --- a/src/controls.rs +++ b/src/controls.rs @@ -29,7 +29,7 @@ impl Direction { } } - pub fn to_position(&self) -> Pos { + pub fn to_position(self) -> Pos { match self { Direction::North => Pos::new(0, -1), Direction::South => Pos::new(0, 1), diff --git a/src/item.rs b/src/item.rs index 420f341..e4dbb34 100644 --- a/src/item.rs +++ b/src/item.rs @@ -41,8 +41,8 @@ impl ItemAction { "eat" => Eat(arg.as_i64()?), "build" => Build( Template::from_json(arg.get(0)?).ok()?, - arg.get(1)?.as_array()?.into_iter().map(|v| Flag::from_str(v.as_str()?)).collect::<Option<HashSet<Flag>>>()?, - arg.get(2)?.as_array()?.into_iter().map(|v| Flag::from_str(v.as_str()?)).collect::<Option<HashSet<Flag>>>()? + arg.get(1)?.as_array()?.iter().map(|v| Flag::from_str(v.as_str()?)).collect::<Option<HashSet<Flag>>>()?, + arg.get(2)?.as_array()?.iter().map(|v| Flag::from_str(v.as_str()?)).collect::<Option<HashSet<Flag>>>()? ), "none" => None, "equip" => Equip(Equippable::from_json(arg)?), diff --git a/src/playerstate.rs b/src/playerstate.rs index acc49ff..0108db2 100644 --- a/src/playerstate.rs +++ b/src/playerstate.rs @@ -109,7 +109,7 @@ impl PlayerState { .ok_or(perr!("inventory does not have items"))? .as_array() .ok_or(perr!("inventory items not an array"))? - .into_iter() + .iter() .map(|entry| { let itemid = ItemId( entry diff --git a/src/template.rs b/src/template.rs index dbaec93..0ad1bc1 100644 --- a/src/template.rs +++ b/src/template.rs @@ -57,7 +57,7 @@ impl Template { "kwargs": v.get(1).ok_or(perr!("index 1 not in template array {:?}", v))? }), Value::Object(_) => v.clone(), - _ => Err(perr!("invalid template {:?}", v))? + _ => return Err(perr!("invalid template {:?}", v)) }; let name = EntityType(val.get("type").ok_or(perr!("template doesn't have 'type'"))?.as_str().ok_or(perr!("template type not a string"))?.to_string()); diff --git a/src/world.rs b/src/world.rs index 0012312..1ffacdc 100644 --- a/src/world.rs +++ b/src/world.rs @@ -36,7 +36,7 @@ impl <'a, 'b>World<'a, 'b> { time: persistence.load_world_meta().unwrap_or(Timestamp(1000000)), persistence, default_room, - encyclopedia: encyclopedia.clone(), + encyclopedia: encyclopedia, players: HashMap::new(), rooms: HashMap::new(), room_age: HashMap::new() |
