From 0535ba3991d4b1d3d0a272020b24897dafa2eeaa Mon Sep 17 00:00:00 2001 From: Fenrir Date: Tue, 13 Feb 2024 23:53:14 -0700 Subject: [PATCH] Use if let instead of unwrap for nullable callback --- ctru-rs/src/applets/swkbd.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/ctru-rs/src/applets/swkbd.rs b/ctru-rs/src/applets/swkbd.rs index d3ab6915..1b7dc134 100644 --- a/ctru-rs/src/applets/swkbd.rs +++ b/ctru-rs/src/applets/swkbd.rs @@ -858,12 +858,14 @@ impl SoftwareKeyboard { let mut retmsg = std::ptr::null(); - swkbd.callback_result = extra.callback.unwrap()( - extra.callback_user, - &mut retmsg, - text8.as_ptr(), - text8.len(), - ) as _; + if let Some(cb) = extra.callback { + swkbd.callback_result = cb( + extra.callback_user, + &mut retmsg, + text8.as_ptr(), + text8.len(), + ) as _ + }; let retmsg = if !retmsg.is_null() { unsafe {