numera/number/integer/nnz/
family.rs

1// numera::integer::nnz::family
2//
3//!
4//
5
6use super::{super::family::define_integer_family, *};
7use crate::number::traits::{
8    ConstLowerBounded, ConstOne, ConstUpperBounded, ConstZero, LowerBounded, NonNegative, One,
9    Positive, UpperBounded, Zero,
10};
11
12define_integer_family![build_variants:
13    NonNegativeIntegers, // the enum name
14    "The family of [non-negative integers][super], also known as [`Nnz`][super::Nnz].",
15    common:
16        NonNegativeInteger+8, NonNegativeInteger+16, NonNegativeInteger+32, NonNegativeInteger+64,
17        NonNegativeInteger+128
18    ;
19
20    depending:
21        Big, NonNegativeIntegerBig, "dashu-int-TODO" // placeholder, disabled
22];
23
24/* impl additional traits for the family */
25
26/* sign */
27
28impl Positive for NonNegativeIntegers {}
29impl NonNegative for NonNegativeIntegers {}
30
31/* ident */
32
33impl Zero for NonNegativeIntegers {
34    /// Returns a [`NonNegativeInteger8::new_zero()`][NonNegativeInteger8#method.new_zero].
35    #[inline]
36    fn new_zero() -> Self {
37        NonNegativeInteger8::new_zero().into()
38    }
39}
40impl One for NonNegativeIntegers {
41    /// Returns a [`NonNegativeInteger8::new_one()`][NonNegativeInteger8#method.new_one].
42    #[inline]
43    fn new_one() -> Self {
44        NonNegativeInteger8::new_one().into()
45    }
46}
47impl ConstZero for NonNegativeIntegers {
48    /// Returns a [`NonNegativeInteger8::ZERO`][NonNegativeInteger8#associatedconstant.ZERO].
49    const ZERO: Self = NonNegativeIntegers::_8(NonNegativeInteger8::ZERO);
50}
51impl ConstOne for NonNegativeIntegers {
52    /// Returns a [`NonNegativeInteger8::ONE`][NonNegativeInteger8#associatedconstant.ONE].
53    const ONE: Self = NonNegativeIntegers::_8(NonNegativeInteger8::ONE);
54}
55
56/* bound */
57
58impl LowerBounded for NonNegativeIntegers {
59    /// Returns a [`NonNegativeInteger8::new_min()`][NonNegativeInteger8#method.new_min].
60    #[inline]
61    fn new_min() -> Self {
62        NonNegativeInteger8::new_min().into()
63    }
64}
65impl UpperBounded for NonNegativeIntegers {
66    /// Returns a [`NonNegativeInteger128::new_max()`][NonNegativeInteger128#method.new_max].
67    #[inline]
68    fn new_max() -> Self {
69        NonNegativeInteger128::new_max().into()
70    }
71}
72impl ConstLowerBounded for NonNegativeIntegers {
73    /// Returns a [`NonNegativeInteger8::MIN`][NonNegativeInteger8#associatedconstant.MIN].
74    const MIN: Self = NonNegativeIntegers::_8(NonNegativeInteger8::MIN);
75}
76impl ConstUpperBounded for NonNegativeIntegers {
77    /// Returns a [`NonNegativeInteger128::MAX`][NonNegativeInteger128#associatedconstant.MAX].
78    const MAX: Self = NonNegativeIntegers::_128(NonNegativeInteger128::MAX);
79}