Skip to content

Commit

Permalink
Use move closures in filter callback examples
Browse files Browse the repository at this point in the history
Trying to capture values by ref won't work for anything that's
not `'static`
  • Loading branch information
FenrirWolf committed Feb 23, 2024
1 parent d4ad0ea commit 7a84ce3
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ctru-rs/examples/software-keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn main() {
// Custom filter callback to handle the given input.
// Using this callback it's possible to integrate the applet
// with custom error messages when the input is incorrect.
keyboard.set_filter_callback(Some(Box::new(|str| {
keyboard.set_filter_callback(Some(Box::new(move |str| {
if str.contains("boo") {
return (CallbackResult::Retry, Some("Ah, you scared me!".into()));
}
Expand Down
2 changes: 1 addition & 1 deletion ctru-rs/src/applets/swkbd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ impl SoftwareKeyboard {
///
/// let mut keyboard = SoftwareKeyboard::default();
///
/// keyboard.set_filter_callback(Some(Box::new(|str| {
/// keyboard.set_filter_callback(Some(Box::new(move |str| {
/// if str.contains("boo") {
/// return (CallbackResult::Retry, Some("Ah, you scared me!".into()));
/// }
Expand Down

0 comments on commit 7a84ce3

Please sign in to comment.