diff options
| author | Freya Murphy <freya@freyacat.org> | 2025-11-14 09:51:12 -0500 |
|---|---|---|
| committer | Freya Murphy <freya@freyacat.org> | 2025-11-14 09:51:12 -0500 |
| commit | 7b78c39cb604961564b1d4e0a491eafacc85e8cb (patch) | |
| tree | 8618f2a4fc76a389bcabdeb94ff46ab6d74b1d77 /dungeon/src/entity.rs | |
| parent | dungeon: refactor manual drop (diff) | |
| download | DungeonCrawl-7b78c39cb604961564b1d4e0a491eafacc85e8cb.tar.gz DungeonCrawl-7b78c39cb604961564b1d4e0a491eafacc85e8cb.tar.bz2 DungeonCrawl-7b78c39cb604961564b1d4e0a491eafacc85e8cb.zip | |
Enable more clippy lints
Diffstat (limited to 'dungeon/src/entity.rs')
| -rw-r--r-- | dungeon/src/entity.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/dungeon/src/entity.rs b/dungeon/src/entity.rs index e3b8fbd..818328c 100644 --- a/dungeon/src/entity.rs +++ b/dungeon/src/entity.rs @@ -46,7 +46,7 @@ pub enum EntityKind { impl EntityKind { /// Returns the move speed value for this type of entity in tiles/s - pub fn move_speed(&self) -> f32 { + pub const fn move_speed(&self) -> f32 { match &self { Self::Player => 5., Self::Zombie(_) => 4., @@ -190,6 +190,7 @@ impl Entity { /// let pos = Pos::new(0, 0).unwrap(); /// let player = Entity::zombie(pos); /// ``` + #[must_use] pub const fn zombie(pos: Pos) -> Self { let dir = Direction::East; let kind = EntityKind::Zombie(EnemyMoveState::new_idle()); @@ -252,9 +253,7 @@ impl Entity { EntityKind::Zombie(EnemyMoveState::new_roam(self.pos, floor, rng)); } EnemyMoveState::Roam(mut moves) => { - let p = if let Some(p) = moves.last() { - p - } else { + let Some(p) = moves.last() else { self.kind = EntityKind::Zombie(EnemyMoveState::new_idle()); return; }; @@ -340,7 +339,7 @@ impl Player { /// let pos = Pos::new(1, 2).unwrap(); /// let player = Player::new(pos); /// ``` - pub fn new(pos: Pos) -> Self { + pub const fn new(pos: Pos) -> Self { let entity = Entity::player(pos); let inventory = vec![]; Self { |