use std::hash::Hash;
use crate::QuantorError;
pub trait QuantorExt<T> {
#[must_use = "Quantifier results must be checked. Use `.is_ok()` or `?` to handle them."]
fn forall<F>(&self, pred: F) -> Result<(), QuantorError>
where
F: Fn(&T) -> bool;
#[must_use = "Quantifier results must be checked. Use `.is_ok()` or `?` to handle them."]
fn exists<F>(&self, pred: F) -> Result<(), QuantorError>
where
F: Fn(&T) -> bool;
#[must_use = "Quantifier results must be checked. Use `.is_ok()` or `?` to handle them."]
fn none<F>(&self, pred: F) -> Result<(), QuantorError>
where
F: Fn(&T) -> bool;
#[must_use = "Quantifier results must be checked. Use `.is_ok()` or `?` to handle them."]
fn exactly_one<F>(&self, pred: F) -> Result<(), QuantorError>
where
F: Fn(&T) -> bool;
#[must_use = "Quantifier results must be checked. Use `.is_ok()` or `?` to handle them."]
fn exactly_n<F>(&self, n: usize, pred: F) -> Result<(), QuantorError>
where
F: Fn(&T) -> bool;
#[must_use = "Quantifier results must be checked. Use `.is_ok()` or `?` to handle them."]
fn all_equal(&self) -> Result<(), QuantorError>
where
T: Eq;
#[must_use = "Quantifier results must be checked. Use `.is_ok()` or `?` to handle them."]
fn forallexists<U, F>(&self, rhs: &[U], pred: F) -> Result<(), QuantorError>
where
F: Fn(&T, &U) -> bool;
#[must_use = "Quantifier results must be checked. Use `.is_ok()` or `?` to handle them."]
fn existsforall<U, F>(&self, rhs: &[U], pred: F) -> Result<(), QuantorError>
where
F: Fn(&T, &U) -> bool;
#[must_use = "Quantifier results must be checked. Use `.is_ok()` or `?` to handle them."]
fn pairwise<F>(&self, pred: F) -> Result<(), QuantorError>
where
F: Fn(&T, &T) -> bool;
#[must_use]
fn failing_elements<F>(&self, pred: F) -> Vec<&T>
where
F: Fn(&T) -> bool;
#[must_use]
fn select_where<F>(&self, pred: F) -> Vec<&T>
where
F: Fn(&T) -> bool;
#[must_use]
fn select_unique<F>(&self, pred: F) -> Vec<&T>
where
F: Fn(&T) -> bool,
T: Eq + std::hash::Hash;
#[must_use]
fn select_duplicates(&self) -> Vec<&T>
where
T: Eq + std::hash::Hash;
}
impl<T, S> QuantorExt<T> for S
where
T: Clone,
S: AsRef<[T]>, {
#[inline]
fn forall<F>(&self, pred: F) -> Result<(), QuantorError>
where F: Fn(&T) -> bool {
crate::quantifiers::basic::forall(self.as_ref(), pred)
}
#[inline]
fn exists<F>(&self, pred: F) -> Result<(), QuantorError>
where F: Fn(&T) -> bool {
crate::quantifiers::basic::exists(self.as_ref(), pred)
}
#[inline]
fn none<F>(&self, pred: F) -> Result<(), QuantorError>
where F: Fn(&T) -> bool {
crate::quantifiers::basic::none(self.as_ref(), pred)
}
#[inline]
fn exactly_one<F>(&self, pred: F) -> Result<(), QuantorError>
where F: Fn(&T) -> bool {
crate::quantifiers::basic::exactly_one(self.as_ref(), pred)
}
#[inline]
fn exactly_n<F>(&self, n: usize, pred: F) -> Result<(), QuantorError>
where F: Fn(&T) -> bool {
crate::quantifiers::basic::exactly_n(self.as_ref(), n, pred)
}
#[inline]
fn all_equal(&self) -> Result<(), QuantorError>
where T: Eq {
crate::quantifiers::basic::all_equal(self.as_ref())
}
#[inline]
fn forallexists<U, F>(&self, rhs: &[U], pred: F) -> Result<(), QuantorError>
where F: Fn(&T, &U) -> bool {
crate::quantifiers::nested::forallexists(self.as_ref(), rhs.iter(), pred)
}
#[inline]
fn existsforall<U, F>(&self, rhs: &[U], pred: F) -> Result<(), QuantorError>
where F: Fn(&T, &U) -> bool {
crate::quantifiers::nested::existsforall(self.as_ref(), rhs.iter(), pred)
}
#[inline]
fn pairwise<F>(&self, pred: F) -> Result<(), QuantorError>
where F: Fn(&T, &T) -> bool {
crate::quantifiers::structured::pairwise(self.as_ref(), pred)
}
#[inline]
fn failing_elements<F>(&self, pred: F) -> Vec<&T>
where F: Fn(&T) -> bool {
crate::quantifiers::structured::failing_elements(self.as_ref(), pred)
}
#[inline]
fn select_where<F>(&self, pred: F) -> Vec<&T>
where F: Fn(&T) -> bool {
crate::quantifiers::selection::select_where(self.as_ref(), pred)
}
#[inline]
fn select_unique<F>(&self, pred: F) -> Vec<&T>
where F: Fn(&T) -> bool,
T: Eq + Hash {
crate::quantifiers::selection::select_unique(self.as_ref(), pred)
}
#[inline]
fn select_duplicates(&self) -> Vec<&T>
where T: Eq + Hash {
crate::quantifiers::selection::select_duplicates(self.as_ref())
}
}