mockall

Trait Predicate

pub trait Predicate<Item>: PredicateReflection
where Item: ?Sized,
{ // Required method fn eval(&self, variable: &Item) -> bool; // Provided method fn find_case<'a>( &'a self, expected: bool, variable: &Item, ) -> Option<Case<'a>> { ... } }
Expand description

Trait for generically evaluating a type against a dynamically created predicate function.

The exact meaning of eval depends on the situation, but will usually mean that the evaluated item is in some sort of pre-defined set. This is different from Ord and Eq in that an item will almost never be the same type as the implementing Predicate type.

Required Methods§

fn eval(&self, variable: &Item) -> bool

Execute this Predicate against variable, returning the resulting boolean.

Provided Methods§

fn find_case<'a>(&'a self, expected: bool, variable: &Item) -> Option<Case<'a>>

Find a case that proves this predicate as expected when run against variable.

Implementations on Foreign Types§

§

impl Predicate<f64> for IsClosePredicate

§

fn eval(&self, variable: &f64) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &f64) -> Option<Case<'a>>

§

impl Predicate<str> for ContainsPredicate

§

fn eval(&self, variable: &str) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<Case<'a>>

§

impl Predicate<str> for DifferencePredicate

§

fn eval(&self, edit: &str) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<Case<'a>>

§

impl Predicate<str> for EndsWithPredicate

§

fn eval(&self, variable: &str) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<Case<'a>>

§

impl Predicate<str> for IsEmptyPredicate

§

fn eval(&self, variable: &str) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<Case<'a>>

§

impl Predicate<str> for MatchesPredicate

§

fn eval(&self, variable: &str) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<Case<'a>>

§

impl Predicate<str> for RegexPredicate

§

fn eval(&self, variable: &str) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<Case<'a>>

§

impl Predicate<str> for StartsWithPredicate

§

fn eval(&self, variable: &str) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<Case<'a>>

§

impl Predicate<str> for StrFilePredicate

§

fn eval(&self, actual: &str) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<Case<'a>>

§

impl Predicate<Path> for BinaryFilePredicate

§

fn eval(&self, path: &Path) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &Path) -> Option<Case<'a>>

§

impl Predicate<Path> for ExistencePredicate

§

fn eval(&self, path: &Path) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &Path) -> Option<Case<'a>>

§

impl Predicate<Path> for FileTypePredicate

§

fn eval(&self, path: &Path) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &Path) -> Option<Case<'a>>

§

impl Predicate<Path> for StrFilePredicate

§

fn eval(&self, path: &Path) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &Path) -> Option<Case<'a>>

§

impl Predicate<[u8]> for BinaryFilePredicate

§

fn eval(&self, actual: &[u8]) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &[u8]) -> Option<Case<'a>>

§

impl<'a, T> Predicate<T> for EqPredicate<&'a T>
where T: Debug + PartialEq + ?Sized,

§

fn eval(&self, variable: &T) -> bool

§

fn find_case<'b>(&'b self, expected: bool, variable: &T) -> Option<Case<'b>>

§

impl<'a, T> Predicate<T> for HashableInPredicate<&'a T>
where T: Hash + Eq + Debug + ?Sized,

§

fn eval(&self, variable: &T) -> bool

§

fn find_case<'b>(&'b self, expected: bool, variable: &T) -> Option<Case<'b>>

§

impl<'a, T> Predicate<T> for InPredicate<&'a T>
where T: PartialEq + Debug + ?Sized,

§

fn eval(&self, variable: &T) -> bool

§

fn find_case<'b>(&'b self, expected: bool, variable: &T) -> Option<Case<'b>>

§

impl<'a, T> Predicate<T> for OrdInPredicate<&'a T>
where T: Ord + Debug + ?Sized,

§

fn eval(&self, variable: &T) -> bool

§

fn find_case<'b>(&'b self, expected: bool, variable: &T) -> Option<Case<'b>>

§

impl<'a, T> Predicate<T> for OrdPredicate<&'a T>
where T: Debug + PartialOrd + ?Sized,

§

fn eval(&self, variable: &T) -> bool

§

fn find_case<'b>(&'b self, expected: bool, variable: &T) -> Option<Case<'b>>

§

impl<F, T> Predicate<T> for FnPredicate<F, T>
where F: Fn(&T) -> bool, T: ?Sized,

§

fn eval(&self, variable: &T) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &T) -> Option<Case<'a>>

§

impl<Item> Predicate<Item> for BooleanPredicate
where Item: ?Sized,

§

fn eval(&self, _variable: &Item) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &Item) -> Option<Case<'a>>

§

impl<Item> Predicate<Item> for BoxPredicate<Item>
where Item: ?Sized,

§

fn eval(&self, variable: &Item) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &Item) -> Option<Case<'a>>

§

impl<M1, M2, Item> Predicate<Item> for AndPredicate<M1, M2, Item>
where M1: Predicate<Item>, M2: Predicate<Item>, Item: ?Sized,

§

fn eval(&self, item: &Item) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &Item) -> Option<Case<'a>>

§

impl<M1, M2, Item> Predicate<Item> for OrPredicate<M1, M2, Item>
where M1: Predicate<Item>, M2: Predicate<Item>, Item: ?Sized,

§

fn eval(&self, item: &Item) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &Item) -> Option<Case<'a>>

§

impl<M, Item> Predicate<Item> for NamePredicate<M, Item>
where M: Predicate<Item>, Item: ?Sized,

§

fn eval(&self, item: &Item) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &Item) -> Option<Case<'a>>

§

impl<M, Item> Predicate<Item> for NotPredicate<M, Item>
where M: Predicate<Item>, Item: ?Sized,

§

fn eval(&self, item: &Item) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &Item) -> Option<Case<'a>>

§

impl<P> Predicate<str> for NormalizedPredicate<P>
where P: Predicate<str>,

§

fn eval(&self, variable: &str) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<Case<'a>>

§

impl<P> Predicate<str> for TrimPredicate<P>
where P: Predicate<str>,

§

fn eval(&self, variable: &str) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &str) -> Option<Case<'a>>

§

impl<P> Predicate<OsStr> for Utf8Predicate<P>
where P: Predicate<str>,

§

fn eval(&self, variable: &OsStr) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &OsStr) -> Option<Case<'a>>

§

impl<P> Predicate<Path> for FileContentPredicate<P>
where P: Predicate<[u8]>,

§

fn eval(&self, path: &Path) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &Path) -> Option<Case<'a>>

§

impl<P> Predicate<[u8]> for Utf8Predicate<P>
where P: Predicate<str>,

§

fn eval(&self, variable: &[u8]) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &[u8]) -> Option<Case<'a>>

§

impl<T> Predicate<T> for EqPredicate<T>
where T: Debug + PartialEq,

§

fn eval(&self, variable: &T) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &T) -> Option<Case<'a>>

§

impl<T> Predicate<T> for HashableInPredicate<T>
where T: Hash + Eq + Debug,

§

fn eval(&self, variable: &T) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &T) -> Option<Case<'a>>

§

impl<T> Predicate<T> for InPredicate<T>
where T: PartialEq + Debug,

§

fn eval(&self, variable: &T) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &T) -> Option<Case<'a>>

§

impl<T> Predicate<T> for OrdInPredicate<T>
where T: Ord + Debug,

§

fn eval(&self, variable: &T) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &T) -> Option<Case<'a>>

§

impl<T> Predicate<T> for OrdPredicate<T>
where T: Debug + PartialOrd,

§

fn eval(&self, variable: &T) -> bool

§

fn find_case<'a>(&'a self, expected: bool, variable: &T) -> Option<Case<'a>>

Implementors§