From a8e9027b4af9dfd5ac68ebcf2253d1330e3d8cc6 Mon Sep 17 00:00:00 2001 From: Freya Murphy Date: Fri, 7 Nov 2025 09:11:12 -0500 Subject: graphics: update get_key_pressed to use try_borrow_mut instead of borrow_mut --- graphics/src/lib.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'graphics') diff --git a/graphics/src/lib.rs b/graphics/src/lib.rs index 9917a94..81ac16e 100644 --- a/graphics/src/lib.rs +++ b/graphics/src/lib.rs @@ -109,7 +109,12 @@ impl Window { /// Get the last key pressed pub fn get_key_pressed(&self) -> Option { - self.handle.borrow_mut().get_key_pressed() + // We dont want to require a mutable reference + // to read the last key pressed + self.handle + .try_borrow_mut() + .ok() + .and_then(|mut h| h.get_key_pressed()) } /// Get audio data for the window -- cgit v1.2.3-freya