reweb3_num/bint/
ops.rs

1use crate::ExpType;
2use core::ops::{
3    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
4    Mul, MulAssign, Neg, Not, Rem, RemAssign, Shl, ShlAssign, Shr, ShrAssign, Sub, SubAssign,
5};
6
7macro_rules! ops {
8    ($BUint: ident, $BInt: ident, $Digit: ident) => {
9        crate::nightly::impl_const! {
10            impl<const N: usize> const Neg for $BInt<N> {
11                type Output = Self;
12
13                #[inline]
14                fn neg(self) -> Self {
15                    Self::neg(self)
16                }
17            }
18        }
19
20        crate::nightly::impl_const! {
21            impl<const N: usize> const Neg for &$BInt<N> {
22                type Output = $BInt<N>;
23
24                #[inline]
25                fn neg(self) -> $BInt<N> {
26                    $BInt::neg(*self)
27                }
28            }
29        }
30
31        crate::nightly::impl_const! {
32            impl<const N: usize> const BitAnd for $BInt<N> {
33                type Output = Self;
34
35                #[inline]
36                fn bitand(self, rhs: Self) -> Self {
37                    Self::bitand(self, rhs)
38                }
39            }
40        }
41
42        crate::nightly::impl_const! {
43            impl<const N: usize> const BitOr for $BInt<N> {
44                type Output = Self;
45
46                #[inline]
47                fn bitor(self, rhs: Self) -> Self {
48                    Self::bitor(self, rhs)
49                }
50            }
51        }
52
53        crate::nightly::impl_const! {
54            impl<const N: usize> const BitXor for $BInt<N> {
55                type Output = Self;
56
57                #[inline]
58                fn bitxor(self, rhs: Self) -> Self {
59                    Self::bitxor(self, rhs)
60                }
61            }
62        }
63
64        crate::nightly::impl_const! {
65            impl<const N: usize> const Div for $BInt<N> {
66                type Output = Self;
67
68                #[inline]
69                fn div(self, rhs: Self) -> Self {
70                    Self::div(self, rhs)
71                }
72            }
73        }
74
75        crate::nightly::impl_const! {
76            impl<const N: usize> const Not for $BInt<N> {
77                type Output = Self;
78
79                fn not(self) -> Self {
80                    Self::not(self)
81                }
82            }
83        }
84
85        crate::nightly::impl_const! {
86            impl<const N: usize> const Rem for $BInt<N> {
87                type Output = Self;
88
89                #[inline]
90                fn rem(self, rhs: Self) -> Self {
91                    Self::rem(self, rhs)
92                }
93            }
94        }
95
96        crate::int::ops::impls!($BInt, $BUint, $BInt);
97    };
98}
99
100crate::macro_impl!(ops);