pub fn pairwise<'a, I, T: 'a, F>(iter: I, pred: F) -> Result<(), QuantorError>Expand description
Checks whether a binary predicate holds for all adjacent pairs.
Equivalent to: ∀(aᵢ, aᵢ₊₁) ∈ self: pred(aᵢ, aᵢ₊₁).
§Arguments
iter- The collection to be checked.pred- The predicate to test each element against.
§Returns
Ok(())if the predicate holds for all adjacent pairs.Err(QuantorError::PairwiseFailed { kind, index })if any pair violates the predicate.
§Example
use quantor::quantifiers::pairwise;
let numbers = vec!(0, 1, 2, 3);
assert!(pairwise(&numbers, |a, b| a < b).is_ok());