use thiserror::Error;
#[derive(Error, Debug, Clone)]
#[non_exhaustive]
pub enum PartialEqError {
#[error("PartialEq::ne MUST always return the negation of PartialEq::eq")]
BadNe,
#[error("a == b MUST imply b == a")]
BrokeSymmetry,
#[error("a == b && b == c MUST imply a == c")]
BrokeTransitivity,
}
#[derive(Error, Debug, Clone)]
#[non_exhaustive]
pub enum EqError {
#[error("a == a MUST be true")]
BrokeReflexivity,
}
#[derive(Error, Debug, Clone)]
#[non_exhaustive]
pub enum PartialOrdError {
#[error("PartialOrd::partial_cmp MUST return Some(Ordering::Equal) if and only if PartialEq::eq returns true")]
BadPartialCmp,
#[error("PartialOrd::lt MUST return true if and only if PartialOrd::partial_cmp returns Some(Ordering::Less)")]
BadLt,
#[error("PartialOrd::le MUST return true if and only if PartialOrd::partial_cmp returns Some(Ordering::Less) or Some(Ordering::Equal)")]
BadLe,
#[error("PartialOrd::gt MUST return true if and only if PartialOrd::partial_cmp returns Some(Ordering::Greater)")]
BadGt,
#[error("PartialOrd::ge MUST return true if and only if PartialOrd::partial_cmp returns Some(Ordering::Greater) or Some(Ordering::Equal)")]
BadGe,
#[error("If a > b, then b < a MUST be true")]
BrokeDuality,
#[error("If a > b and b > c, then a > c MUST be true. The same must hold true for <")]
BrokeTransitivity,
}
#[derive(Error, Debug, Clone)]
#[non_exhaustive]
pub enum OrdError {
#[error("`cmp` and `partial_cmp` are not consistent")]
BadCmp,
#[error("`cmp` and `max` are not consistent")]
BadMax,
#[error("`cmp` and `min` are not consistent")]
BadMin,
#[error("`cmp` and `clamp` are not consistent")]
BadClamp,
}
#[derive(Error, Debug, Clone)]
#[non_exhaustive]
pub enum HashError {
#[error("Equal values MUST have equal hash values")]
EqualButDifferentHashes,
#[error("When two values are different, one of the two hash outputs CAN NOT be a prefix of the other")]
PrefixCollision,
}
#[derive(Error, Debug, Clone)]
#[non_exhaustive]
pub enum IteratorError {
#[error("Iterator::size_hint MUST always provide correct lower and upper bounds")]
BadSizeHint,
#[error(
"Iterator::count MUST be consistent with the actual number of elements returned by .next()"
)]
BadCount,
#[error(".last() MUST be equal to the last element of the Vec<_> resulting from .collect()")]
BadLast,
#[error("DoubleEndedIterator::next_back() MUST return the same values as .next(), but in reverse order")]
BadNextBack,
#[error("FusedIterator MUST return None indefinitely after exhaustion")]
FusedIteratorReturnedSomeAfterExhaustion,
}
#[derive(Error, Debug, Clone)]
#[non_exhaustive]
pub enum Error {
#[error(transparent)]
PartialEq(#[from] PartialEqError),
#[error(transparent)]
Eq(#[from] EqError),
#[error(transparent)]
PartiaOrd(#[from] PartialOrdError),
#[error(transparent)]
Ord(#[from] OrdError),
#[error(transparent)]
Hash(#[from] HashError),
#[error(transparent)]
Iterator(#[from] IteratorError),
}