Mercurial > lbo > hg > localmr
changeset 61:bcf1cc002325
Implement Ord for Record
author | Lewin Bormann <lbo@spheniscida.de> |
---|---|
date | Fri, 05 Feb 2016 23:00:59 +0000 |
parents | c8cab29a9d89 |
children | 1608d4061077 |
files | src/record_types.rs |
diffstat | 1 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/record_types.rs Fri Feb 05 22:01:44 2016 +0000 +++ b/src/record_types.rs Fri Feb 05 23:00:59 2016 +0000 @@ -10,9 +10,18 @@ impl PartialOrd for Record { fn partial_cmp(&self, other: &Record) -> Option<Ordering> { + Some(match self.key.cmp(&other.key) { + Ordering::Equal => self.value.cmp(&other.value), + o => o, + }) + } +} + +impl Ord for Record { + fn cmp(&self, other: &Record) -> Ordering { match self.key.cmp(&other.key) { - Ordering::Equal => Some(self.value.cmp(&other.value)), - o => Some(o), + Ordering::Equal => self.value.cmp(&other.value), + o => o, } } }