diff options
author | HampusM <hampus@hampusmat.com> | 2024-11-11 00:30:07 +0100 |
---|---|---|
committer | HampusM <hampus@hampusmat.com> | 2024-11-11 00:30:07 +0100 |
commit | 85eaffed104e53c149f58f08aacbf7f7d532a94d (patch) | |
tree | 88d126459956bb6b1aeb97c9ea715b7e48055c26 /engine/src/input.rs | |
parent | 7c5c87d316df31bfe732872df10eaa1a4b6f3a12 (diff) |
refactor(engine): fix clippy lints
Diffstat (limited to 'engine/src/input.rs')
-rw-r--r-- | engine/src/input.rs | 19 |
1 files changed, 13 insertions, 6 deletions
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; } |