From 12d102b39c3b2104436bdd6321bd33e3e65f2473 Mon Sep 17 00:00:00 2001 From: Aurabindo Pillai Date: Mon, 4 Dec 2023 01:01:19 +0000 Subject: [PATCH] Fix some clippy warnings --- jid/src/inner.rs | 8 ++++---- jid/src/lib.rs | 8 ++++---- xmpp/src/pubsub/mod.rs | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/jid/src/inner.rs b/jid/src/inner.rs index 644e4c25..e6a3418b 100644 --- a/jid/src/inner.rs +++ b/jid/src/inner.rs @@ -108,9 +108,9 @@ impl InnerJid { } pub(crate) fn node(&self) -> Option<&str> { - self.at.and_then(|at| { + self.at.map(|at| { let at = u16::from(at) as usize; - Some(&self.normalized[..at]) + &self.normalized[..at] }) } @@ -134,9 +134,9 @@ impl InnerJid { } pub(crate) fn resource(&self) -> Option<&str> { - self.slash.and_then(|slash| { + self.slash.map(|slash| { let slash = u16::from(slash) as usize; - Some(&self.normalized[slash + 1..]) + &self.normalized[slash + 1..] }) } } diff --git a/jid/src/lib.rs b/jid/src/lib.rs index 34d70247..6f746a2d 100644 --- a/jid/src/lib.rs +++ b/jid/src/lib.rs @@ -148,7 +148,7 @@ impl Jid { pub fn node(&self) -> Option { match self { Jid::Bare(BareJid { inner }) | Jid::Full(FullJid { inner }) => { - inner.node().map(|s| NodePart::new_unchecked(s)) + inner.node().map(NodePart::new_unchecked) } } } @@ -181,7 +181,7 @@ impl Jid { pub fn resource(&self) -> Option { match self { Jid::Bare(BareJid { inner }) | Jid::Full(FullJid { inner }) => { - inner.resource().map(|s| ResourcePart::new_unchecked(s)) + inner.resource().map(ResourcePart::new_unchecked) } } } @@ -470,7 +470,7 @@ impl FullJid { /// The optional node part of the JID, as a [`NodePart`] pub fn node(&self) -> Option { - self.node_str().map(|s| NodePart::new_unchecked(s)) + self.node_str().map(NodePart::new_unchecked) } /// The optional node part of the JID, as a stringy reference @@ -587,7 +587,7 @@ impl BareJid { /// The optional node part of the JID, as a [`NodePart`] pub fn node(&self) -> Option { - self.node_str().map(|s| NodePart::new_unchecked(s)) + self.node_str().map(NodePart::new_unchecked) } /// The optional node part of the JID, as a stringy reference diff --git a/xmpp/src/pubsub/mod.rs b/xmpp/src/pubsub/mod.rs index 363bcd20..9234a097 100644 --- a/xmpp/src/pubsub/mod.rs +++ b/xmpp/src/pubsub/mod.rs @@ -72,7 +72,7 @@ pub(crate) async fn handle_event(from: &Jid, elem: Element, agent: &mut Agent) - } ref node => unimplemented!("node {}", node), } - }, + } Err(e) => { error!("Error parsing PubSub event: {}", e); }