From f6f6faeb77bceff83a4cf2d6ea467b90b3597b67 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Thu, 20 Jul 2017 23:08:23 +0100 Subject: [PATCH] iq, jingle_ft: Simplify item counting with Iterator::count(). --- src/iq.rs | 2 +- src/jingle_ft.rs | 2 +- src/presence.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/iq.rs b/src/iq.rs index d1078b3..aed6a83 100644 --- a/src/iq.rs +++ b/src/iq.rs @@ -222,7 +222,7 @@ impl TryFrom for Iq { return Err(Error::ParseError("Wrong number of children in iq element.")); } error_payload = Some(StanzaError::try_from(elem.clone())?); - } else if root.children().collect::>().len() != 2 { + } else if root.children().count() != 2 { return Err(Error::ParseError("Wrong number of children in iq element.")); } } else { diff --git a/src/jingle_ft.rs b/src/jingle_ft.rs index 7bd0df8..85ac2df 100644 --- a/src/jingle_ft.rs +++ b/src/jingle_ft.rs @@ -91,7 +91,7 @@ impl TryFrom for Description { if !elem.is("description", ns::JINGLE_FT) { return Err(Error::ParseError("This is not a JingleFT description element.")); } - if elem.children().collect::>().len() != 1 { + if elem.children().count() != 1 { return Err(Error::ParseError("JingleFT description element must have exactly one child.")); } diff --git a/src/presence.rs b/src/presence.rs index 30a2615..a0147c7 100644 --- a/src/presence.rs +++ b/src/presence.rs @@ -485,6 +485,6 @@ mod tests { presence.statuses.insert(String::from(""), status); let elem: Element = presence.into(); assert!(elem.is("presence", ns::JABBER_CLIENT)); - assert!(elem.children().collect::>()[0].is("status", ns::JABBER_CLIENT)); + assert!(elem.children().next().unwrap().is("status", ns::JABBER_CLIENT)); } }