From 141a40bc79c64db52eca066fbf38b837ea0e2fa8 Mon Sep 17 00:00:00 2001 From: xmppftw Date: Fri, 29 Dec 2023 15:01:59 +0100 Subject: [PATCH] Derive PartialOrd/Ord for Jid types --- jid/src/inner.rs | 2 +- jid/src/lib.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/jid/src/inner.rs b/jid/src/inner.rs index e6a3418b..ec7c5a6f 100644 --- a/jid/src/inner.rs +++ b/jid/src/inner.rs @@ -27,7 +27,7 @@ fn length_check(len: usize, error_empty: Error, error_too_long: Error) -> Result } } -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] pub(crate) struct InnerJid { pub(crate) normalized: String, pub(crate) at: Option, diff --git a/jid/src/lib.rs b/jid/src/lib.rs index ada59384..d5374d2f 100644 --- a/jid/src/lib.rs +++ b/jid/src/lib.rs @@ -54,7 +54,7 @@ pub use parts::{DomainPart, NodePart, ResourcePart}; /// An enum representing a Jabber ID. It can be either a `FullJid` or a `BareJid`. #[cfg_attr(feature = "serde", derive(Serialize, Deserialize))] #[cfg_attr(feature = "serde", serde(untagged))] -#[derive(Debug, Clone, PartialEq, Eq, Hash)] +#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] pub enum Jid { /// Contains a [`BareJid`], without a resource part Bare(BareJid), @@ -281,7 +281,7 @@ impl PartialEq for Jid { /// Unlike a [`BareJid`], it always contains a resource, and should only be used when you are /// certain there is no case where a resource can be missing. Otherwise, use a [`Jid`] or /// [`BareJid`]. -#[derive(Clone, PartialEq, Eq, Hash)] +#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct FullJid { inner: InnerJid, } @@ -294,7 +294,7 @@ pub struct FullJid { /// /// Unlike a [`FullJid`], it can’t contain a resource, and should only be used when you are certain /// there is no case where a resource can be set. Otherwise, use a [`Jid`] or [`FullJid`]. -#[derive(Clone, PartialEq, Eq, Hash)] +#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] pub struct BareJid { inner: InnerJid, }