Browse Source

use `if let` in panic hook instead of `match`

pull/162/head
Fenrir 10 months ago
parent
commit
a65b9ed577
  1. 7
      ctru-rs/src/applets/error.rs

7
ctru-rs/src/applets/error.rs

@ -108,8 +108,7 @@ pub fn set_panic_hook(use_stderr: bool) {
// If we get a `WouldBlock` error, we know that the `Gfx` service has been initialized. // If we get a `WouldBlock` error, we know that the `Gfx` service has been initialized.
// Otherwise fallback to printing over stderr. // Otherwise fallback to printing over stderr.
match GFX_ACTIVE.try_lock() { if let Err(TryLockError::WouldBlock) = GFX_ACTIVE.try_lock() {
Err(TryLockError::WouldBlock) => {
if use_stderr { if use_stderr {
print_to_stderr(name, panic_info); print_to_stderr(name, panic_info);
} }
@ -123,11 +122,9 @@ pub fn set_panic_hook(use_stderr: bool) {
unsafe { unsafe {
popup.launch_unchecked(); popup.launch_unchecked();
} }
} } else {
_ => {
print_to_stderr(name, panic_info); print_to_stderr(name, panic_info);
} }
}
})); }));
fn print_to_stderr(name: &str, panic_info: &std::panic::PanicInfo) { fn print_to_stderr(name: &str, panic_info: &std::panic::PanicInfo) {

Loading…
Cancel
Save