pub struct DefaultNotAllowedError;Expand description
Useful pre-made error
Implementations§
Source§impl DefaultNotAllowedError
impl DefaultNotAllowedError
Sourcepub fn new_box_result<T>() -> BoxResult<T>
pub fn new_box_result<T>() -> BoxResult<T>
Easily get a return value
Examples found in repository?
examples/custom_tryread.rs (line 22)
21 fn try_read_line(self, prompt: Option<String>, default: Option<Self::Default>) -> smart_read::BoxResult<Self::Output> {
22 if default.is_some() {return DefaultNotAllowedError::new_box_result();}
23 let prompt = prompt.unwrap_or_else(
24 || format!("Enter a password (must have {}+ characters and have {}+ digits): ", self.min_len, self.min_digits)
25 );
26 loop {
27
28 print!("{prompt}");
29 let password = read_stdin()?;
30
31 if password.len() < 10 {
32 println!("Password must have at least 10 characters");
33 continue;
34 }
35 if password.chars().filter(|c| c.is_digit(10)).count() < 1 {
36 println!("Password must have at least 1 digit");
37 continue;
38 }
39
40 return Ok(password)
41
42 }
43 }Trait Implementations§
Source§impl Debug for DefaultNotAllowedError
impl Debug for DefaultNotAllowedError
Source§impl Display for DefaultNotAllowedError
impl Display for DefaultNotAllowedError
Source§impl Error for DefaultNotAllowedError
impl Error for DefaultNotAllowedError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for DefaultNotAllowedError
impl RefUnwindSafe for DefaultNotAllowedError
impl Send for DefaultNotAllowedError
impl Sync for DefaultNotAllowedError
impl Unpin for DefaultNotAllowedError
impl UnwindSafe for DefaultNotAllowedError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more