From 85eaffed104e53c149f58f08aacbf7f7d532a94d Mon Sep 17 00:00:00 2001 From: HampusM Date: Mon, 11 Nov 2024 00:30:07 +0100 Subject: refactor(engine): fix clippy lints --- engine/src/file_format/wavefront/common.rs | 2 +- engine/src/input.rs | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'engine/src') diff --git a/engine/src/file_format/wavefront/common.rs b/engine/src/file_format/wavefront/common.rs index b3fec66..8cdfb34 100644 --- a/engine/src/file_format/wavefront/common.rs +++ b/engine/src/file_format/wavefront/common.rs @@ -241,7 +241,7 @@ impl Value })?)); } - if value.chars().all(|character| character.is_ascii()) { + if value.is_ascii() { return Ok(Self::Text(value.to_string())); } diff --git a/engine/src/input.rs b/engine/src/input.rs index d1fb336..f4166f6 100644 --- a/engine/src/input.rs +++ b/engine/src/input.rs @@ -49,16 +49,21 @@ impl Keys #[must_use] pub fn get_key_state(&self, key: Key) -> KeyState { - self.map.get(&key).expect("Key not in key map").state + let Some(key_data) = self.map.get(&key) else { + unreachable!(); + }; + + key_data.state } #[must_use] pub fn get_prev_key_state(&self, key: Key) -> KeyState { - self.map - .get(&key) - .expect("Key not in key map") - .prev_tick_state + let Some(key_data) = self.map.get(&key) else { + unreachable!(); + }; + + key_data.prev_tick_state } pub fn set_key_state(&mut self, key: Key, new_key_state: KeyState) @@ -67,7 +72,9 @@ impl Keys return; } - let key_data = self.map.get_mut(&key).expect("Key not in key map"); + let Some(key_data) = self.map.get_mut(&key) else { + unreachable!(); + }; key_data.state = new_key_state; } -- cgit v1.2.3-18-g5258