numera/number/integer/n0z/
family.rs

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