Clippy - example 6
@@ -75,7 +75,7 @@ impl State {
return false;
}
let idx = (y * 80) + x;
- return self.map[idx as usize] == TileType::Floor;
+ self.map[idx as usize] == TileType::Floor
}
}
@@ -103,8 +103,7 @@ impl GameState for State {
// Iterate the map array, incrementing coordinates as we go.
let mut y = 0;
let mut x = 0;
- let mut i: usize = 0;
- for tile in self.map.iter() {
+ for (i,tile) in self.map.iter().enumerate() {
// Render a tile depending upon the tile type; now we check visibility as well!
let mut fg;
let mut glyph = ".";
@@ -129,7 +128,6 @@ impl GameState for State {
x = 0;
y += 1;
}
- i += 1;
}
// Either render the proposed path or run along it
@@ -168,7 +166,7 @@ impl GameState for State {
} else {
self.player_position = self.path.steps[0] as usize;
self.path.steps.remove(0);
- if self.path.steps.len() == 0 {
+ if self.path.steps.is_empty() {
self.mode = Mode::Waiting;
}
}
@@ -223,13 +221,13 @@ impl BaseMap for State {
exits.push(((idx + 80) + 1, 1.4));
}
- return exits;
+ exits
}
fn get_pathing_distance(&self, idx1: i32, idx2: i32) -> f32 {
let p1 = Point::new(idx1 % 80, idx1 / 80);
let p2 = Point::new(idx2 % 80, idx2 / 80);
- return rltk::distance2d(DistanceAlg::Pythagoras, p1, p2);
+ rltk::distance2d(DistanceAlg::Pythagoras, p1, p2)
}
}
