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
use crate::nightly::impl_const;
use core::cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd};

macro_rules! cmp {
    ($BUint: ident, $BInt: ident, $Digit: ident) => {
        impl_const! {
            impl<const N: usize> const PartialEq for $BInt<N> {
                #[inline]
                fn eq(&self, other: &Self) -> bool {
                    Self::eq(self, other)
                }
            }
        }

        impl<const N: usize> Eq for $BInt<N> {}

        impl_const! {
            impl<const N: usize> const PartialOrd for $BInt<N> {
                #[inline]
                fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
                    Some(self.cmp(other))
                }
            }
        }

        impl_const! {
            impl<const N: usize> const Ord for $BInt<N> {
                #[inline]
                fn cmp(&self, other: &Self) -> Ordering {
                    Self::cmp(self, other)
                }

                #[inline]
                fn max(self, other: Self) -> Self {
                    Self::max(self, other)
                }

                #[inline]
                fn min(self, other: Self) -> Self {
                    Self::min(self, other)
                }

                #[inline]
                fn clamp(self, min: Self, max: Self) -> Self {
                    Self::clamp(self, min, max)
                }
            }
        }

        #[cfg(test)]
        paste::paste! {
            mod [<$Digit _digit_tests>] {
                use crate::test::types::big_types::$Digit::*;
                crate::int::cmp::tests!(itest);
            }
        }
    };
}

crate::macro_impl!(cmp);