diff --git a/ctru-rs/examples/software-keyboard.rs b/ctru-rs/examples/software-keyboard.rs index b0b79f8..144b587 100644 --- a/ctru-rs/examples/software-keyboard.rs +++ b/ctru-rs/examples/software-keyboard.rs @@ -21,10 +21,7 @@ fn main() { // with custom error messages when the input is incorrect. keyboard.set_filter_callback(Some(Box::new(|str| { if str.contains("boo") { - return ( - CallbackResult::Retry, - Some(String::from("Ah, you scared me!")), - ); + return (CallbackResult::Retry, Some("Ah, you scared me!".into())); } (CallbackResult::Ok, None) diff --git a/ctru-rs/src/applets/swkbd.rs b/ctru-rs/src/applets/swkbd.rs index a674b24..f5d7c68 100644 --- a/ctru-rs/src/applets/swkbd.rs +++ b/ctru-rs/src/applets/swkbd.rs @@ -12,12 +12,13 @@ use ctru_sys::{ use bitflags::bitflags; +use std::borrow::Cow; use std::ffi::{CStr, CString}; use std::fmt::Display; use std::iter::once; use std::str; -type CallbackFunction = dyn Fn(&str) -> (CallbackResult, Option); +type CallbackFunction = dyn Fn(&str) -> (CallbackResult, Option>); /// Configuration structure to setup the Software Keyboard applet. #[doc(alias = "SwkbdState")] @@ -342,17 +343,13 @@ impl SoftwareKeyboard { /// # fn main() { /// # /// use std::borrow::Cow; - /// use std::ffi::CString; /// use ctru::applets::swkbd::{SoftwareKeyboard, CallbackResult}; /// /// let mut keyboard = SoftwareKeyboard::default(); /// /// keyboard.set_filter_callback(Some(Box::new(|str| { /// if str.contains("boo") { - /// return ( - /// CallbackResult::Retry, - /// Some(String::from("Ah, you scared me!")), - /// ); + /// return (CallbackResult::Retry, Some("Ah, you scared me!".into())); /// } /// /// (CallbackResult::Ok, None)