Skip to main content

PredicateExt

Trait PredicateExt 

Source
pub trait PredicateExt: Sized + Predicate {
    // Provided methods
    fn and<R>(self, right: R) -> And<Self, R>
       where R: Predicate<Subject = Self::Subject> { ... }
    fn or<R>(self, right: R) -> Or<Self, R>
       where R: Predicate<Subject = Self::Subject> { ... }
    fn not(self) -> Not<Self> { ... }
    fn boxed(self) -> Box<dyn Predicate<Subject = Self::Subject> + Sync + Send>
       where Self: Send + Sync + 'static { ... }
}
Expand description

Extension trait for fluent predicate composition.

Provided Methods§

Source

fn and<R>(self, right: R) -> And<Self, R>
where R: Predicate<Subject = Self::Subject>,

Combines this predicate with another using AND logic.

Returns Cacheable only if both predicates return Cacheable.

Source

fn or<R>(self, right: R) -> Or<Self, R>
where R: Predicate<Subject = Self::Subject>,

Combines this predicate with another using OR logic.

Returns Cacheable if either predicate returns Cacheable.

Source

fn not(self) -> Not<Self>

Inverts this predicate’s result.

Cacheable becomes NonCacheable and vice versa.

Source

fn boxed(self) -> Box<dyn Predicate<Subject = Self::Subject> + Sync + Send>
where Self: Send + Sync + 'static,

Boxes this predicate into a trait object.

Useful for type erasure when storing predicates in collections or returning them from functions.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T> PredicateExt for T
where T: Predicate,