Skip to main content

Not

Struct Not 

Source
pub struct Not<A>(/* private fields */);
Expand description

Passes exactly when the sub-rule A fails.

Not inverts any Validator, regardless of its error type, and reports a ValidationError with code "not" when A unexpectedly passes.

§Examples

use type_lib::combinator::Not;
use type_lib::rules::Ascii;
use type_lib::Validator;

// Require that a string is *not* pure ASCII.
type NonAscii = Not<Ascii>;

assert!(NonAscii::validate("café").is_ok()); // not ASCII -> passes
assert!(NonAscii::validate("plain").is_err()); // ASCII -> fails

Trait Implementations§

Source§

impl<T, A> Validator<T> for Not<A>
where T: ?Sized, A: Validator<T>,

Source§

type Error = ValidationError

The failure produced when a value violates the rule. Read more
Source§

fn validate(value: &T) -> Result<(), Self::Error>

Checks value against the rule. Read more

Auto Trait Implementations§

§

impl<A> Freeze for Not<A>

§

impl<A> RefUnwindSafe for Not<A>

§

impl<A> Send for Not<A>

§

impl<A> Sync for Not<A>

§

impl<A> Unpin for Not<A>

§

impl<A> UnsafeUnpin for Not<A>

§

impl<A> UnwindSafe for Not<A>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.