Skip to content

Commit

Permalink
Variable name and style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
FenrirWolf committed Mar 21, 2024
1 parent d8cffcf commit 6791bf6
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions ctru-rs/src/applets/swkbd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -437,13 +437,13 @@ impl SoftwareKeyboard {
#[doc(alias = "swkbdSetHintText")]
pub fn set_hint_text(&mut self, text: Option<&str>) {
if let Some(text) = text {
for (idx, code_point) in text
for (idx, code_unit) in text
.encode_utf16()
.take(self.state.hint_text.len() - 1)
.chain(once(0))
.enumerate()
{
self.state.hint_text[idx] = code_point;
self.state.hint_text[idx] = code_unit;
}
} else {
self.state.hint_text[0] = 0;
Expand Down Expand Up @@ -732,15 +732,15 @@ impl SoftwareKeyboard {
// We need to pass a thin pointer to the boxed closure over FFI. Since we know that the message callback will finish before
// `self` is allowed to be moved again, we can safely use a pointer to the local value contained in `self.filter_callback`
// The cast here is also sound since the pointer will only be read from if `self.filter_callback.is_some()` returns true.
let mut message_callback_data = MessageCallbackData {
let mut data = MessageCallbackData {
filter_callback: std::ptr::addr_of!(self.filter_callback).cast(),
swkbd_shared_mem_ptr,
};

if self.filter_callback.is_some() {
aptSetMessageCallback(
Some(Self::swkbd_message_callback),
std::ptr::addr_of_mut!(message_callback_data).cast(),
std::ptr::addr_of_mut!(data).cast(),
)
}

Expand Down Expand Up @@ -827,9 +827,7 @@ impl SoftwareKeyboard {

let text8 = text16.to_string();

let filter_callback = unsafe { &**data.filter_callback };

let (result, retmsg) = filter_callback(&text8);
let (result, retmsg) = unsafe { &**data.filter_callback }(&text8);

Check warning on line 830 in ctru-rs/src/applets/swkbd.rs

View workflow job for this annotation

GitHub Actions / lint (nightly-2024-02-18)

this expression borrows a value the compiler would automatically borrow

swkbd.callback_result = result as _;

Expand Down

0 comments on commit 6791bf6

Please sign in to comment.