diff options
author | Neal H. Walfield <neal@pep.foundation> | 2019-09-02 11:44:25 +0200 |
---|---|---|
committer | Neal H. Walfield <neal@pep.foundation> | 2019-09-02 13:32:02 +0200 |
commit | 3f94eb91b87a3cd5034ae26f4f7e773e67af3d6e (patch) | |
tree | 6f56bbd33e3a6b5c4d074c332a960f000f24fb96 | |
parent | fcdf939e7596b663bd467d82069d7cf2716a007d (diff) |
openpgp: Implement Ord for UserID
-rw-r--r-- | openpgp/src/packet/userid.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/openpgp/src/packet/userid.rs b/openpgp/src/packet/userid.rs index e8db9bdd..ca47f620 100644 --- a/openpgp/src/packet/userid.rs +++ b/openpgp/src/packet/userid.rs @@ -2,6 +2,8 @@ use std::fmt; use std::str; use std::hash::{Hash, Hasher}; use std::cell::RefCell; +use std::cmp::Ordering; + use quickcheck::{Arbitrary, Gen}; use crate::rfc2822::{ AddrSpec, @@ -122,6 +124,17 @@ impl PartialEq for UserID { impl Eq for UserID { } +impl PartialOrd for UserID { + fn partial_cmp(&self, other: &Self) -> Option<Ordering> { + Some(self.cmp(other)) + } +} + +impl Ord for UserID { + fn cmp(&self, other: &Self) -> Ordering { + self.value.cmp(&other.value) + } +} impl Hash for UserID { fn hash<H: Hasher>(&self, state: &mut H) { |