From 11087d64f7d3f62594aa5bbfedc750949e6c7d98 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 30 Jul 2023 14:48:32 +0200 Subject: [PATCH] Add *Jid::into_inner() returning the inner String Thanks pep. for the suggestion! --- jid/src/lib.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/jid/src/lib.rs b/jid/src/lib.rs index 74a2a3f..bf28db5 100644 --- a/jid/src/lib.rs +++ b/jid/src/lib.rs @@ -117,6 +117,13 @@ impl Jid { } } + /// Returns the inner String of this JID. + pub fn into_inner(self) -> String { + match self { + Jid::Bare(BareJid { inner }) | Jid::Full(FullJid { inner }) => inner.normalized, + } + } + /// Build a [`Jid`] from typed parts. This method cannot fail because it uses parts that have /// already been parsed and stringprepped into [`NodePart`], [`DomainPart`], and [`ResourcePart`]. /// This method allocates and does not consume the typed parts. @@ -391,6 +398,11 @@ impl FullJid { } } + /// Returns the inner String of this JID. + pub fn into_inner(self) -> String { + self.inner.normalized + } + /// Build a [`FullJid`] from typed parts. This method cannot fail because it uses parts that have /// already been parsed and stringprepped into [`NodePart`], [`DomainPart`], and [`ResourcePart`]. /// This method allocates and does not consume the typed parts. @@ -496,6 +508,11 @@ impl BareJid { } } + /// Returns the inner String of this JID. + pub fn into_inner(self) -> String { + self.inner.normalized + } + /// Build a [`BareJid`] from typed parts. This method cannot fail because it uses parts that have /// already been parsed and stringprepped into [`NodePart`] and [`DomainPart`]. This method allocates /// and does not consume the typed parts.