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
use std::cmp::Ordering;
#[derive(Eq, PartialEq)]
pub struct Bytes32<'a> {
pub store: Vec<[&'a u8; 4]>,
}
impl<'a> Ord for Bytes32<'a> {
fn cmp(&self, other: &Bytes32) -> Ordering {
for _i in 0..3 {
if other.store[_i] > self.store[_i] {
return Ordering::Greater;
}
if other.store[_i] < self.store[_i] {
return Ordering::Less;
}
}
Ordering::Equal
}
}
impl<'a> PartialOrd for Bytes32<'a> {
fn partial_cmp(&self, other: &Bytes32) -> Option<Ordering> {
Some(self.cmp(other))
}
}