From eb5633dbf0b03f98a630152528ea310f05dbf173 Mon Sep 17 00:00:00 2001 From: inyourface3445 Date: Tue, 5 Nov 2024 10:01:27 -0500 Subject: [PATCH] changed from using .is_none to unwrapping it ... and assigning it to a varible --- plastic_tui/src/ui.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/plastic_tui/src/ui.rs b/plastic_tui/src/ui.rs index 0b5f3c1..385aa29 100644 --- a/plastic_tui/src/ui.rs +++ b/plastic_tui/src/ui.rs @@ -451,21 +451,18 @@ impl Ui { fn handle_gamepad(&mut self) { // set events in the cache and check if gamepad is still active - if self.gilrs.is_none() { + let Some(gilrs_obj) = self.gilrs.as_mut() else { return; - } + }; - while let Some(GilrsEvent { id, event, .. }) = self.gilrs.as_mut().unwrap().next_event() { + while let Some(GilrsEvent { id, event, .. }) = gilrs_obj.next_event() { self.active_gamepad = Some(id); if event == EventType::Disconnected { self.active_gamepad = None; } } - if let Some(gamepad) = self - .active_gamepad - .map(|id| self.gilrs.as_mut().unwrap().gamepad(id)) - { + if let Some(gamepad) = self.active_gamepad.map(|id| gilrs_obj.gamepad(id)) { for (controller_button, nes_button) in &[ (Button::South, NESKey::B), (Button::East, NESKey::A),