Trait predicates::boolean::PredicateBooleanExt

source ·
pub trait PredicateBooleanExt<Item: ?Sized>
where Self: Predicate<Item>,
{ // Provided methods fn and<B>(self, other: B) -> AndPredicate<Self, B, Item> where B: Predicate<Item>, Self: Sized { ... } fn or<B>(self, other: B) -> OrPredicate<Self, B, Item> where B: Predicate<Item>, Self: Sized { ... } fn not(self) -> NotPredicate<Self, Item> where Self: Sized { ... } }
Expand description

Predicate extension that adds boolean logic.

Provided Methods§

source

fn and<B>(self, other: B) -> AndPredicate<Self, B, Item>
where B: Predicate<Item>, Self: Sized,

Compute the logical AND of two Predicate results, returning the result.

§Examples
use predicates::prelude::*;

let predicate_fn1 = predicate::always().and(predicate::always());
let predicate_fn2 = predicate::always().and(predicate::never());
assert_eq!(true, predicate_fn1.eval(&4));
assert_eq!(false, predicate_fn2.eval(&4));
source

fn or<B>(self, other: B) -> OrPredicate<Self, B, Item>
where B: Predicate<Item>, Self: Sized,

Compute the logical OR of two Predicate results, returning the result.

§Examples
use predicates::prelude::*;

let predicate_fn1 = predicate::always().or(predicate::always());
let predicate_fn2 = predicate::always().or(predicate::never());
let predicate_fn3 = predicate::never().or(predicate::never());
assert_eq!(true, predicate_fn1.eval(&4));
assert_eq!(true, predicate_fn2.eval(&4));
assert_eq!(false, predicate_fn3.eval(&4));
source

fn not(self) -> NotPredicate<Self, Item>
where Self: Sized,

Compute the logical NOT of a Predicate, returning the result.

§Examples
use predicates::prelude::*;

let predicate_fn1 = predicate::always().not();
let predicate_fn2 = predicate::never().not();
assert_eq!(false, predicate_fn1.eval(&4));
assert_eq!(true, predicate_fn2.eval(&4));

Implementors§

source§

impl<P, Item> PredicateBooleanExt<Item> for P
where P: Predicate<Item>, Item: ?Sized,