pub trait InputValidator<T> {
type Err;
fn validate(&mut self, input: &T) -> Result<(), Self::Err>;
}
impl<T, F, E> InputValidator<T> for F
where
F: FnMut(&T) -> Result<(), E>,
{
type Err = E;
fn validate(&mut self, input: &T) -> Result<(), Self::Err> {
self(input)
}
}
#[allow(clippy::ptr_arg)]
pub trait PasswordValidator {
type Err;
fn validate(&self, input: &String) -> Result<(), Self::Err>;
}
impl<F, E> PasswordValidator for F
where
F: Fn(&String) -> Result<(), E>,
{
type Err = E;
fn validate(&self, input: &String) -> Result<(), Self::Err> {
self(input)
}
}