Struct smart_read::DefaultNotAllowedError
source · 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_readline.rs (line 21)
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
fn try_read_line(&self, prompt: Option<String>, default: Option<Self::Output>) -> smart_read::BoxResult<Self::Output> {
if default.is_some() {return DefaultNotAllowedError::new_box_result();}
let prompt = prompt.unwrap_or_else(
|| format!("Enter a password (must have {}+ characters and have {}+ digits): ", self.min_len, self.min_digits)
);
loop {
print!("{prompt}");
let password = read_stdin()?;
if password.len() < 10 {
println!("Password must have at least 10 characters");
continue;
}
if password.chars().filter(|c| c.is_digit(10)).count() < 1 {
println!("Password must have at least 1 digit");
continue;
}
return Ok(password)
}
}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)>
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