Skip to content

Commit

Permalink
Use if let instead of unwrap for nullable callback
Browse files Browse the repository at this point in the history
  • Loading branch information
FenrirWolf committed Feb 14, 2024
1 parent 65f7d26 commit 0535ba3
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ctru-rs/src/applets/swkbd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 0535ba3

Please sign in to comment.