pub use sign::NonZeroSign as NonZeroSign;
pub use sign::NonZeroSigned as NonZeroSigned;
pub mod sign;
pub trait NonZero {
fn is_not_zero(&self) -> bool;
}
macro_rules! could_be_zero {
($($t:ty),+ $(,)?) => {$(
impl NonZero for $t {
#[inline]
fn is_not_zero(&self) -> bool {
!num_traits::Zero::is_zero(self)
}
}
)+}
}
could_be_zero!(i8, i16, i32, i64, i128, isize);
could_be_zero!(u8, u16, u32, u64, u128, usize);
could_be_zero!(f32, f64);
macro_rules! can_not_be_zero {
($($t:ty),+ $(,)?) => {$(
impl NonZero for std::num::NonZero<$t> {
#[inline]
fn is_not_zero(&self) -> bool {
true
}
}
)+}
}
can_not_be_zero!(i8, i16, i32, i64, i128, isize);
can_not_be_zero!(u8, u16, u32, u64, u128, usize);