From b0e665f5436e08e4fd7446a59b87ac28f562a601 Mon Sep 17 00:00:00 2001 From: troido Date: Sun, 9 Feb 2020 23:54:24 +0100 Subject: refactoring using cargo clippy --- src/systems/moving.rs | 4 ++-- src/systems/view.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/systems') diff --git a/src/systems/moving.rs b/src/systems/moving.rs index 98b0979..3e7803d 100644 --- a/src/systems/moving.rs +++ b/src/systems/moving.rs @@ -74,8 +74,8 @@ impl <'a> System<'a> for Move { let mut pos_mut = pos.get_mut_unchecked(); moved.insert(ent, Moved{from: pos_mut.pos}).expect("can't insert Moved"); ground.cells.get_mut(&pos_mut.pos).unwrap().remove(&ent); - pos_mut.pos = newpos.clone(); - ground.cells.entry(newpos).or_insert(HashSet::new()).insert(ent); + pos_mut.pos = newpos; + ground.cells.entry(newpos).or_insert_with(HashSet::new).insert(ent); } } _ => {} diff --git a/src/systems/view.rs b/src/systems/view.rs index 6c0b1f8..a884d35 100644 --- a/src/systems/view.rs +++ b/src/systems/view.rs @@ -48,7 +48,7 @@ impl <'a> System<'a> for View { } - let has_changed: bool = changed.len() > 0; + let has_changed: bool = !changed.is_empty(); let mut changes: Vec<(Pos, Vec)> = Vec::new(); for pos in changed { changes.push((pos, cell_sprites(ground.cells.get(&pos).unwrap_or(&HashSet::new()), &visible))); @@ -92,7 +92,7 @@ fn draw_room(ground: &HashMap>, (width, height): (i64, i64) let mut mapping: Vec> = Vec::new(); for y in 0..height { for x in 0..width { - let sprites: Vec = match ground.get(&Pos{x: x, y: y}) { + let sprites: Vec = match ground.get(&Pos{x, y}) { Some(ents) => {cell_sprites(ents, visible)} None => {vec![]} }; -- cgit