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
//! Module containing macros for implementing `core::ops` traits.

macro_rules! impl_cmp {
    (
        impl Cmp for $int:ident ($prim:ident);
    ) => {
        impl PartialOrd for $int {
            #[inline]
            fn partial_cmp(&self, other: &Self) -> Option<::core::cmp::Ordering> {
                Some(self.cmp(other))
            }
        }

        impl PartialEq<$prim> for $int {
            #[inline]
            fn eq(&self, other: &$prim) -> bool {
                *self == $int::new(*other)
            }
        }

        impl PartialEq<$int> for $prim {
            #[inline]
            fn eq(&self, other: &$int) -> bool {
                $int::new(*self) == *other
            }
        }

        impl PartialOrd<$prim> for $int {
            #[inline]
            fn partial_cmp(&self, rhs: &$prim) -> Option<::core::cmp::Ordering> {
                Some(self.cmp(&$int::new(*rhs)))
            }
        }

        impl PartialOrd<$int> for $prim {
            #[inline]
            fn partial_cmp(&self, rhs: &$int) -> Option<::core::cmp::Ordering> {
                Some($int::new(*self).cmp(rhs))
            }
        }
    };
}