use super::{super::family::define_integer_family, *};
use crate::{
error::NumeraResult,
number::traits::{
ConstLowerBounded, ConstNegOne, ConstUpperBounded, ConstZero, LowerBounded, NegOne,
Negative, NonPositive, UpperBounded, Zero,
},
};
define_integer_family![build_variants:
NonPositiveIntegers,
"The family of [non-positive integers][super], also known as [`Npz`][super::Npz].",
common:
NonPositiveInteger+8, NonPositiveInteger+16, NonPositiveInteger+32, NonPositiveInteger+64,
NonPositiveInteger+128
;
depending:
Big, NonPositiveIntegerBig, "dashu-int-TODO" ];
impl Negative for NonPositiveIntegers {}
impl NonPositive for NonPositiveIntegers {
type InnerRepr = Self;
#[inline]
fn new_neg(value: Self::InnerRepr) -> NumeraResult<Self> {
Ok(value)
}
}
impl Zero for NonPositiveIntegers {
#[inline]
fn new_zero() -> Self {
NonPositiveInteger8::new_zero().into()
}
}
impl NegOne for NonPositiveIntegers {
#[inline]
fn new_neg_one() -> Self {
NonPositiveInteger8::new_neg_one().into()
}
}
impl ConstZero for NonPositiveIntegers {
const ZERO: Self = NonPositiveIntegers::_8(NonPositiveInteger8::ZERO);
}
impl ConstNegOne for NonPositiveIntegers {
const NEG_ONE: Self = NonPositiveIntegers::_8(NonPositiveInteger8::NEG_ONE);
}
impl LowerBounded for NonPositiveIntegers {
#[inline]
fn new_min() -> Self {
NonPositiveInteger128::new_min().into()
}
}
impl UpperBounded for NonPositiveIntegers {
#[inline]
fn new_max() -> Self {
NonPositiveInteger8::new_max().into()
}
}
impl ConstLowerBounded for NonPositiveIntegers {
const MIN: Self = NonPositiveIntegers::_128(NonPositiveInteger128::MIN);
}
impl ConstUpperBounded for NonPositiveIntegers {
const MAX: Self = NonPositiveIntegers::_8(NonPositiveInteger8::MAX);
}