reweb3_num/buint/
cmp.rs

1use crate::nightly::impl_const;
2use core::cmp::{Ord, Ordering, PartialOrd};
3
4macro_rules! cmp {
5    ($BUint: ident, $BInt: ident, $Digit: ident) => {
6        // impl_const! {
7        //     impl<const N: usize> const PartialEq for $BUint<N> {
8        //         #[inline]
9        //         fn eq(&self, other: &Self) -> bool {
10        //             Self::eq(self, other)
11        //         }
12        //     }
13        // }
14
15        // impl<const N: usize> Eq for $BUint<N> {}
16
17        impl_const! {
18            impl<const N: usize> const PartialOrd for $BUint<N> {
19                #[inline]
20                fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
21                    Some(self.cmp(other))
22                }
23            }
24        }
25
26        impl_const! {
27            impl<const N: usize> const Ord for $BUint<N> {
28                #[inline]
29                fn cmp(&self, other: &Self) -> Ordering {
30                    Self::cmp(self, other)
31                }
32
33                #[inline]
34                fn max(self, other: Self) -> Self {
35                    Self::max(self, other)
36                }
37
38                #[inline]
39                fn min(self, other: Self) -> Self {
40                    Self::min(self, other)
41                }
42
43                #[inline]
44                fn clamp(self, min: Self, max: Self) -> Self {
45                    Self::clamp(self, min, max)
46                }
47            }
48        }
49    };
50}
51
52crate::macro_impl!(cmp);