summaryrefslogtreecommitdiff
path: root/src/systems
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-02-09 23:54:24 +0100
committertroido <troido@protonmail.com>2020-02-09 23:54:24 +0100
commitb0e665f5436e08e4fd7446a59b87ac28f562a601 (patch)
treefcdeee5178606eadfe1e1b5744410bfd4fef260a /src/systems
parentb9cfb78c20fd309929aae98f24acc8ba4a9a7481 (diff)
refactoring using cargo clippy
Diffstat (limited to 'src/systems')
-rw-r--r--src/systems/moving.rs4
-rw-r--r--src/systems/view.rs4
2 files changed, 4 insertions, 4 deletions
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<String>)> = 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<Pos, HashSet<Entity>>, (width, height): (i64, i64)
let mut mapping: Vec<Vec<String>> = Vec::new();
for y in 0..height {
for x in 0..width {
- let sprites: Vec<String> = match ground.get(&Pos{x: x, y: y}) {
+ let sprites: Vec<String> = match ground.get(&Pos{x, y}) {
Some(ents) => {cell_sprites(ents, visible)}
None => {vec![]}
};