Stirct ordering for hashes.

This commit is contained in:
Gav Wood 2016-01-13 12:16:10 +01:00
parent 6447f9b90b
commit 4be539a965

View File

@ -224,16 +224,22 @@ macro_rules! impl_hash {
} }
} }
impl PartialOrd for $from { impl Ord for $from {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { fn cmp(&self, other: &Self) -> Ordering {
for i in 0..$size { for i in 0..$size {
if self.0[i] > other.0[i] { if self.0[i] > other.0[i] {
return Some(Ordering::Greater); return Ordering::Greater;
} else if self.0[i] < other.0[i] { } else if self.0[i] < other.0[i] {
return Some(Ordering::Less); return Ordering::Less;
} }
} }
Some(Ordering::Equal) Ordering::Equal
}
}
impl PartialOrd for $from {
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
Some(self.cmp(other))
} }
} }