From a65b9ed57738ae50c4df67fbd657713fa24d1201 Mon Sep 17 00:00:00 2001 From: Fenrir Date: Sun, 25 Feb 2024 02:06:24 -0700 Subject: [PATCH] use `if let` in panic hook instead of `match` --- ctru-rs/src/applets/error.rs | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/ctru-rs/src/applets/error.rs b/ctru-rs/src/applets/error.rs index 6fa7efc..b723aa8 100644 --- a/ctru-rs/src/applets/error.rs +++ b/ctru-rs/src/applets/error.rs @@ -108,25 +108,22 @@ pub fn set_panic_hook(use_stderr: bool) { // If we get a `WouldBlock` error, we know that the `Gfx` service has been initialized. // Otherwise fallback to printing over stderr. - match GFX_ACTIVE.try_lock() { - Err(TryLockError::WouldBlock) => { - if use_stderr { - print_to_stderr(name, panic_info); - } + if let Err(TryLockError::WouldBlock) = GFX_ACTIVE.try_lock() { + if use_stderr { + print_to_stderr(name, panic_info); + } - let payload = format!("thread '{name}' {panic_info}"); + let payload = format!("thread '{name}' {panic_info}"); - let mut popup = PopUp::new(Kind::Top); + let mut popup = PopUp::new(Kind::Top); - popup.set_text(&payload); + popup.set_text(&payload); - unsafe { - popup.launch_unchecked(); - } - } - _ => { - print_to_stderr(name, panic_info); + unsafe { + popup.launch_unchecked(); } + } else { + print_to_stderr(name, panic_info); } }));