Skip to main content

FnStatefulPredicateOps

Trait FnStatefulPredicateOps 

Source
pub trait FnStatefulPredicateOps<T>: FnMut(&T) -> bool + Sized {
    // Provided methods
    fn and<P>(self, other: P) -> BoxStatefulPredicate<T>
       where Self: 'static,
             P: StatefulPredicate<T> + 'static,
             T: 'static { ... }
    fn or<P>(self, other: P) -> BoxStatefulPredicate<T>
       where Self: 'static,
             P: StatefulPredicate<T> + 'static,
             T: 'static { ... }
    fn not(self) -> BoxStatefulPredicate<T>
       where Self: 'static,
             T: 'static { ... }
    fn nand<P>(self, other: P) -> BoxStatefulPredicate<T>
       where Self: 'static,
             P: StatefulPredicate<T> + 'static,
             T: 'static { ... }
    fn xor<P>(self, other: P) -> BoxStatefulPredicate<T>
       where Self: 'static,
             P: StatefulPredicate<T> + 'static,
             T: 'static { ... }
    fn nor<P>(self, other: P) -> BoxStatefulPredicate<T>
       where Self: 'static,
             P: StatefulPredicate<T> + 'static,
             T: 'static { ... }
}
Expand description

Extension trait providing logical composition methods for stateful closures.

This trait is implemented for closures and function objects matching FnMut(&T) -> bool, allowing direct composition into BoxStatefulPredicate.

Provided Methods§

Source

fn and<P>(self, other: P) -> BoxStatefulPredicate<T>
where Self: 'static, P: StatefulPredicate<T> + 'static, T: 'static,

Returns a predicate representing logical AND with another predicate.

This method consumes self and evaluates other only when this closure returns true.

§Parameters
  • other - The other predicate to combine with.
§Returns

A BoxStatefulPredicate representing logical AND.

Source

fn or<P>(self, other: P) -> BoxStatefulPredicate<T>
where Self: 'static, P: StatefulPredicate<T> + 'static, T: 'static,

Returns a predicate representing logical OR with another predicate.

This method consumes self and evaluates other only when this closure returns false.

§Parameters
  • other - The other predicate to combine with.
§Returns

A BoxStatefulPredicate representing logical OR.

Source

fn not(self) -> BoxStatefulPredicate<T>
where Self: 'static, T: 'static,

Returns a predicate representing logical negation.

This method consumes self and returns a predicate that negates the closure result.

§Returns

A BoxStatefulPredicate representing logical negation.

Source

fn nand<P>(self, other: P) -> BoxStatefulPredicate<T>
where Self: 'static, P: StatefulPredicate<T> + 'static, T: 'static,

Returns a predicate representing logical NAND with another predicate.

NAND returns true unless both predicates return true.

§Parameters
  • other - The other predicate to combine with.
§Returns

A BoxStatefulPredicate representing logical NAND.

Source

fn xor<P>(self, other: P) -> BoxStatefulPredicate<T>
where Self: 'static, P: StatefulPredicate<T> + 'static, T: 'static,

Returns a predicate representing logical XOR with another predicate.

XOR evaluates both predicates and returns true when exactly one predicate returns true.

§Parameters
  • other - The other predicate to combine with.
§Returns

A BoxStatefulPredicate representing logical XOR.

Source

fn nor<P>(self, other: P) -> BoxStatefulPredicate<T>
where Self: 'static, P: StatefulPredicate<T> + 'static, T: 'static,

Returns a predicate representing logical NOR with another predicate.

NOR returns true only when both predicates return false.

§Parameters
  • other - The other predicate to combine with.
§Returns

A BoxStatefulPredicate representing logical NOR.

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, F> FnStatefulPredicateOps<T> for F
where F: FnMut(&T) -> bool,