mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
iq, jingle_ft: Simplify item counting with Iterator::count().
This commit is contained in:
parent
2571aa7666
commit
f6f6faeb77
3 changed files with 3 additions and 3 deletions
|
@ -222,7 +222,7 @@ impl TryFrom<Element> 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::<Vec<_>>().len() != 2 {
|
||||
} else if root.children().count() != 2 {
|
||||
return Err(Error::ParseError("Wrong number of children in iq element."));
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -91,7 +91,7 @@ impl TryFrom<Element> for Description {
|
|||
if !elem.is("description", ns::JINGLE_FT) {
|
||||
return Err(Error::ParseError("This is not a JingleFT description element."));
|
||||
}
|
||||
if elem.children().collect::<Vec<_>>().len() != 1 {
|
||||
if elem.children().count() != 1 {
|
||||
return Err(Error::ParseError("JingleFT description element must have exactly one child."));
|
||||
}
|
||||
|
||||
|
|
|
@ -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::<Vec<_>>()[0].is("status", ns::JABBER_CLIENT));
|
||||
assert!(elem.children().next().unwrap().is("status", ns::JABBER_CLIENT));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue