#![allow(unused_imports)]
use super::*;
pub trait FnPredicateOps<T>: Fn(&T) -> bool + Sized {
fn and<P>(self, other: P) -> BoxPredicate<T>
where
Self: 'static,
P: Predicate<T> + 'static,
T: 'static,
{
BoxPredicate::new(move |value: &T| self.test(value) && other.test(value))
}
fn or<P>(self, other: P) -> BoxPredicate<T>
where
Self: 'static,
P: Predicate<T> + 'static,
T: 'static,
{
BoxPredicate::new(move |value: &T| self.test(value) || other.test(value))
}
fn not(self) -> BoxPredicate<T>
where
Self: 'static,
T: 'static,
{
BoxPredicate::new(move |value: &T| !self.test(value))
}
fn nand<P>(self, other: P) -> BoxPredicate<T>
where
Self: 'static,
P: Predicate<T> + 'static,
T: 'static,
{
BoxPredicate::new(move |value: &T| !(self.test(value) && other.test(value)))
}
fn xor<P>(self, other: P) -> BoxPredicate<T>
where
Self: 'static,
P: Predicate<T> + 'static,
T: 'static,
{
BoxPredicate::new(move |value: &T| self.test(value) ^ other.test(value))
}
fn nor<P>(self, other: P) -> BoxPredicate<T>
where
Self: 'static,
P: Predicate<T> + 'static,
T: 'static,
{
BoxPredicate::new(move |value: &T| !(self.test(value) || other.test(value)))
}
}
impl<T, F> FnPredicateOps<T> for F where F: Fn(&T) -> bool {}