Skip to main content

coda/num/
cmp.rs

1#![macro_use]
2macro_rules! impl_cmp {
3    ($name:ident, $type:ty) => {
4        impl PartialEq for $name {
5            fn eq(&self, other: &Self) -> bool {
6                self.mask().0 == other.mask().0
7            }
8        }
9
10        impl Eq for $name {}
11
12        impl PartialOrd for $name {
13            fn partial_cmp(&self, other: &$name) -> Option<Ordering> {
14                self.mask().0.partial_cmp(&other.mask().0)
15            }
16        }
17
18        impl Ord for $name {
19            fn cmp(&self, other: &$name) -> Ordering {
20                self.mask().0.cmp(&other.mask().0)
21            }
22        }
23
24        impl Hash for $name {
25            fn hash<H: Hasher>(&self, h: &mut H) {
26                self.mask().0.hash(h)
27            }
28        }
29    };
30}