pub mod usize {
use {
crate::{Sigma, Test},
core::fmt,
};
pub type LessThan<const N: usize> = Sigma<usize, LessThanInvariant<N>>;
#[derive(Clone, Copy, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct LessThanInvariant<const N: usize>;
impl<const N: usize> Test<usize, 1> for LessThanInvariant<N> {
const ADJECTIVE: &str = "positive";
type Error<'i>
= NotLessThan<'i, N>
where
usize: 'i;
#[inline(always)]
fn test([input]: [&usize; 1]) -> Result<(), Self::Error<'_>> {
if *input < N {
Ok(())
} else {
Err(NotLessThan(input))
}
}
}
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct NotLessThan<'i, const N: usize>(&'i usize);
impl<const N: usize> fmt::Display for NotLessThan<'_, N> {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
#![expect(
clippy::use_debug,
reason = "Intentional and informative, not just forgotten print-debugging"
)]
let Self(z) = *self;
write!(f, "{z:#?} >= {N:#?}")
}
}
}