From 1ffd583bea0a88b727cb0dacfbdcfbc31ed99ca5 Mon Sep 17 00:00:00 2001 From: Guillaume Pasquet Date: Sun, 17 Nov 2019 02:08:03 +0000 Subject: Clean up code with clippy --- src/entities.rs | 14 +++++++------- src/main.rs | 2 +- src/tiling.rs | 2 +- src/world.rs | 19 ++++++------------- 4 files changed, 15 insertions(+), 22 deletions(-) diff --git a/src/entities.rs b/src/entities.rs index 80e1235..b0169c8 100644 --- a/src/entities.rs +++ b/src/entities.rs @@ -123,7 +123,7 @@ impl Enemy for Character { luck, level: 0, xp: 0, - location: location, + location, previous_location: location, tile_type: TileType::Character, dirty: false, @@ -145,13 +145,13 @@ impl Player for Character { luck: i32, ) -> Character { Character { - name: name, - class: class, + name, + class, max_health: health, - health: health, - attack: attack, - dodge: dodge, - luck: luck, + health, + attack, + dodge, + luck, xp: 0, level: 0, location: (0, 0), diff --git a/src/main.rs b/src/main.rs index 2e45c58..f890a27 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,7 +8,7 @@ mod state; mod tiling; mod world; -use entities::{Character, Entity, Player}; +use entities::{Entity, Player}; use pancurses::{endwin, initscr, noecho, Input}; use state::State; use std::env; diff --git a/src/tiling.rs b/src/tiling.rs index ef2b90b..2b6da80 100644 --- a/src/tiling.rs +++ b/src/tiling.rs @@ -18,7 +18,7 @@ impl TileGrid { grid.grid.push(subvec); } - return grid; + grid } pub fn set_tile(&mut self, x: usize, y: usize, tile: TileType) { diff --git a/src/world.rs b/src/world.rs index baddf48..328c15c 100644 --- a/src/world.rs +++ b/src/world.rs @@ -6,13 +6,6 @@ use std::cmp::min; pub type Point = (usize, usize); pub type Movement = (i8, i8); -pub enum Direction { - North, - South, - East, - West, -} - enum CorridorType { Horizontal, Vertical, @@ -283,15 +276,15 @@ impl Level { } pub fn get_start_point(&self) -> Point { - if self.rooms.len() > 0 { + if self.rooms.is_empty() { return self.rooms[0].center; } - return (0, 0); + (0, 0) } - pub fn get_entrance(&self) -> Point { - self.entrance - } + // pub fn get_entrance(&self) -> Point { + // self.entrance + // } pub fn get_exit(&self) -> Point { self.exit @@ -308,7 +301,7 @@ impl Level { } } - return false; + false } fn room_distances(&self, point: Point) -> Vec<(usize, f32)> { -- cgit v1.2.3