Browse Source

Use `move` closures in filter callback examples

Trying to capture values by ref won't work for anything that's
not `'static`
pull/163/head
Fenrir 10 months ago
parent
commit
7a84ce3d70
  1. 2
      ctru-rs/examples/software-keyboard.rs
  2. 2
      ctru-rs/src/applets/swkbd.rs

2
ctru-rs/examples/software-keyboard.rs

@ -19,7 +19,7 @@ fn main() { @@ -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()));
}

2
ctru-rs/src/applets/swkbd.rs

@ -348,7 +348,7 @@ impl SoftwareKeyboard { @@ -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()));
/// }

Loading…
Cancel
Save