aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTuomas Siipola2016-11-23 22:57:40 +0200
committerTuomas Siipola2016-11-23 22:57:40 +0200
commit720b115f3aa8402f23c9eff927c447502e7d524b (patch)
tree07d22dbe8796a72e177a6f78484fa9105428c1dd
parenta3a216978799dbfe58fab601e8fa98e249ce3f9f (diff)
Fix warnings by clippy
-rw-r--r--src/font.rs4
-rw-r--r--src/game.rs8
-rw-r--r--src/main.rs8
3 files changed, 9 insertions, 11 deletions
diff --git a/src/font.rs b/src/font.rs
index 5edd17f..c3cf11d 100644
--- a/src/font.rs
+++ b/src/font.rs
@@ -50,7 +50,7 @@ impl Font {
pub fn draw(&self, renderer: &mut Renderer, x: i32, y: i32, text: &str) {
let mut position = x;
for byte in text.bytes() {
- position += if byte == ' ' as u8 {
+ position += if byte == b' ' {
SPACE_WIDTH as i32
} else {
let character = self.get_character(byte);
@@ -65,7 +65,7 @@ impl Font {
pub fn measure(&self, text: &str) -> u32 {
text.bytes().fold(0, |acc, byte| {
acc +
- if byte == ' ' as u8 {
+ if byte == b' ' {
SPACE_WIDTH
} else {
self.get_character(byte).width
diff --git a/src/game.rs b/src/game.rs
index cc6312e..79d0eb4 100644
--- a/src/game.rs
+++ b/src/game.rs
@@ -41,11 +41,11 @@ impl Game {
for x in 0..32 {
for y in 0..23 {
- update_tile(renderer, &tiles, &game.map, x, y);
+ update_tile(renderer, tiles, &game.map, x, y);
}
}
- place_food(&mut game.map, renderer, &tiles);
+ place_food(&mut game.map, renderer, tiles);
game
}
@@ -59,7 +59,7 @@ pub fn place_food(map: &mut Map, renderer: &mut Renderer, tiles: &Texture) {
continue;
}
map.tiles[x as usize][y as usize] = Tile::Food;
- update_tile(renderer, &tiles, &map, x, y);
+ update_tile(renderer, tiles, map, x, y);
break;
}
}
@@ -72,7 +72,7 @@ pub fn update_tile(renderer: &mut Renderer, tiles: &Texture, map: &Map, x: i32,
renderer.fill_rect(target_rect).unwrap();
}
tile => {
- renderer.copy(&tiles,
+ renderer.copy(tiles,
Some(Rect::new(match tile {
Tile::Wall(i) => 150 + 10 * i as i32,
Tile::Food => 140,
diff --git a/src/main.rs b/src/main.rs
index 77a0310..ee5f53d 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -67,11 +67,9 @@ fn main() {
Scancode::A => Direction::Left,
_ => next_direction,
}
- } else {
- if scancode == Scancode::R {
- game = Game::new(&mut renderer, &font, &tiles, &map);
- continue 'running;
- }
+ } else if scancode == Scancode::R {
+ game = Game::new(&mut renderer, &font, &tiles, &map);
+ continue 'running;
}
}
_ => {}