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§
sourcefn and<B>(self, other: B) -> AndPredicate<Self, B, Item>
fn and<B>(self, other: B) -> AndPredicate<Self, B, Item>
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));
sourcefn or<B>(self, other: B) -> OrPredicate<Self, B, Item>
fn or<B>(self, other: B) -> OrPredicate<Self, B, Item>
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));
sourcefn not(self) -> NotPredicate<Self, Item>where
Self: Sized,
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));