predicates_core

Trait Predicate

Source
pub trait Predicate<Item: ?Sized>: PredicateReflection {
    // 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§

Source

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

Execute this Predicate against variable, returning the resulting boolean.

Provided Methods§

Source

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.

Implementors§

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

impl<'a, P, T> Predicate<T> for AncestorPredicate<P>
where T: Captured<'a>, P: for<'p> Predicate<CapturedSpan<'p>>,

impl<'a, P, T> Predicate<T> for ParentPredicate<P>
where T: Captured<'a>, P: for<'p> Predicate<CapturedSpan<'p>>,

impl<'a, P: Predicate<TracedValue>, T: Captured<'a>> Predicate<T> for FieldPredicate<P>

impl<'a, P: Predicate<str>, T: Captured<'a>> Predicate<T> for TargetPredicate<P>

impl<'a, P: Predicate<Level>, T: Captured<'a>> Predicate<T> for LevelPredicate<P>

impl<T, P> Predicate<TracedValue> for ValuePredicate<T, P>
where T: for<'a> FromTracedValue<'a> + ?Sized, P: Predicate<T>,

impl<T, U, Item: ?Sized> Predicate<Item> for And<T, U>
where T: Predicate<Item>, U: Predicate<Item>,

impl<T, U, Item: ?Sized> Predicate<Item> for Or<T, U>
where T: Predicate<Item>, U: Predicate<Item>,