1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
use crate::ExpType;
use core::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Mul, MulAssign, Neg, Not, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub, SubAssign,
};

macro_rules! ops {
    ($BUint: ident, $BInt: ident, $Digit: ident) => {
        crate::nightly::impl_const! {
            impl<const N: usize> const Neg for $BInt<N> {
                type Output = Self;

                #[inline]
                fn neg(self) -> Self {
                    Self::neg(self)
                }
            }
        }

        crate::nightly::impl_const! {
            impl<const N: usize> const Neg for &$BInt<N> {
                type Output = $BInt<N>;

                #[inline]
                fn neg(self) -> $BInt<N> {
                    $BInt::neg(*self)
                }
            }
        }

        crate::nightly::impl_const! {
            impl<const N: usize> const BitAnd for $BInt<N> {
                type Output = Self;

                #[inline]
                fn bitand(self, rhs: Self) -> Self {
                    Self::bitand(self, rhs)
                }
            }
        }

        crate::nightly::impl_const! {
            impl<const N: usize> const BitOr for $BInt<N> {
                type Output = Self;

                #[inline]
                fn bitor(self, rhs: Self) -> Self {
                    Self::bitor(self, rhs)
                }
            }
        }

        crate::nightly::impl_const! {
            impl<const N: usize> const BitXor for $BInt<N> {
                type Output = Self;

                #[inline]
                fn bitxor(self, rhs: Self) -> Self {
                    Self::bitxor(self, rhs)
                }
            }
        }

        crate::nightly::impl_const! {
            impl<const N: usize> const Div for $BInt<N> {
                type Output = Self;

                #[inline]
                fn div(self, rhs: Self) -> Self {
                    Self::div(self, rhs)
                }
            }
        }

        crate::nightly::impl_const! {
            impl<const N: usize> const Not for $BInt<N> {
                type Output = Self;

                fn not(self) -> Self {
                    Self::not(self)
                }
            }
        }

        crate::nightly::impl_const! {
            impl<const N: usize> const Rem for $BInt<N> {
                type Output = Self;

                #[inline]
                fn rem(self, rhs: Self) -> Self {
                    Self::rem(self, rhs)
                }
            }
        }

        crate::int::ops::impls!($BInt, $BUint, $BInt);

        #[cfg(test)]
        paste::paste! {
            mod [<$Digit _digit_tests>] {
                use super::*;
                use crate::test::{debug_skip, test_bignum, types::itest};
                use crate::test::types::big_types::$Digit::*;

                crate::int::ops::tests!(itest);

                test_bignum! {
                    function: <itest>::neg(a: itest),
                    skip: debug_skip!(a == itest::MIN)
                }
            }
        }
    };
}

crate::macro_impl!(ops);