use core::num::*;
#[allow(clippy::declare_interior_mutable_const)]
pub trait Zero {
const ZERO: Self;
}
#[allow(clippy::declare_interior_mutable_const)]
pub trait One {
const ONE: Self;
}
#[allow(clippy::declare_interior_mutable_const)]
pub trait Two {
const TWO: Self;
}
#[allow(clippy::declare_interior_mutable_const)]
pub trait NegativeOne {
const NEGATIVE_ONE: Self;
}
#[allow(clippy::declare_interior_mutable_const)]
pub trait OneHalf {
const ONE_HALF: Self;
}
#[allow(clippy::declare_interior_mutable_const)]
pub trait NegativeZero {
const NEGATIVE_ZERO: Self;
}
#[allow(clippy::declare_interior_mutable_const)]
pub trait Infinity {
const INFINITY: Self;
}
#[allow(clippy::declare_interior_mutable_const)]
pub trait NegativeInfinity {
const NEGATIVE_INFINITY: Self;
}
#[allow(clippy::declare_interior_mutable_const)]
pub trait NaN {
const NAN: Self;
}
macro_rules! impl_non_zero {
($($t:ident),+) => {
$(
impl One for $t {
const ONE: Self = match Self::new(1) {
Some(v) => v,
None => unreachable!() };
}
impl Two for $t {
const TWO: Self = match Self::new(2) {
Some(v) => v,
None => unreachable!() };
}
)+
};
($($u:ident && $i:ident),+) => {
$(
impl_non_zero!($u, $i);
impl NegativeOne for $i {
const NEGATIVE_ONE: Self = match Self::new(-1) {
Some(v) => v,
None => unreachable!() };
}
)+
}
}
impl_non_zero!(
NonZeroUsize && NonZeroIsize,
NonZeroU128 && NonZeroI128,
NonZeroU64 && NonZeroI64,
NonZeroU32 && NonZeroI32,
NonZeroU16 && NonZeroI16,
NonZeroU8 && NonZeroI8
);