Trait mockall::Predicate

pub trait Predicate<Item>: PredicateReflectionwhere
    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§

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl Predicate<str> for RegexPredicate

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl Predicate<str> for MatchesPredicate

source§

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

source§

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

source§

impl Predicate<str> for EndsWithPredicate

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl Predicate<str> for ContainsPredicate

source§

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

source§

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

source§

impl Predicate<Path> for StrFilePredicate

source§

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

source§

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

source§

impl Predicate<str> for IsEmptyPredicate

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl Predicate<Path> for ExistencePredicate

source§

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

source§

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

source§

impl Predicate<[u8]> for BinaryFilePredicate

source§

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

source§

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

source§

impl Predicate<str> for StrFilePredicate

source§

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

source§

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

source§

impl Predicate<str> for StartsWithPredicate

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl<Item> Predicate<Item> for BooleanPredicatewhere Item: ?Sized,

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl Predicate<Path> for FileTypePredicate

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl Predicate<str> for DifferencePredicate

source§

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

source§

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

source§

impl Predicate<Path> for BinaryFilePredicate

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl Predicate<f64> for IsClosePredicate

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

source§

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

Implementors§