diff --git a/jid/src/lib.rs b/jid/src/lib.rs index aa9e294b..dd5f734a 100644 --- a/jid/src/lib.rs +++ b/jid/src/lib.rs @@ -149,6 +149,42 @@ impl TryFrom for FullJid { } } +impl PartialEq for FullJid { + fn eq(&self, other: &Jid) -> bool { + match other { + Jid::Full(full) => self == full, + Jid::Bare(_) => false, + } + } +} + +impl PartialEq for BareJid { + fn eq(&self, other: &Jid) -> bool { + match other { + Jid::Full(_) => false, + Jid::Bare(bare) => self == bare, + } + } +} + +impl PartialEq for Jid { + fn eq(&self, other: &FullJid) -> bool { + match self { + Jid::Full(full) => full == other, + Jid::Bare(_) => false, + } + } +} + +impl PartialEq for Jid { + fn eq(&self, other: &BareJid) -> bool { + match self { + Jid::Full(_) => false, + Jid::Bare(bare) => bare == other, + } + } +} + /// A struct representing a full Jabber ID. /// /// A full Jabber ID is composed of 3 components, of which one is optional: