mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
minidom: clippy pass
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
2b433d7036
commit
60ebcb8c8a
3 changed files with 24 additions and 25 deletions
|
@ -400,7 +400,7 @@ impl Element {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let namespace = if self.namespace.len() == 0 {
|
let namespace = if self.namespace.is_empty() {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(Arc::new(self.namespace.clone().try_into()?))
|
Some(Arc::new(self.namespace.clone().try_into()?))
|
||||||
|
@ -712,7 +712,7 @@ impl Element {
|
||||||
/// Remove the leading nodes up to the first child element and
|
/// Remove the leading nodes up to the first child element and
|
||||||
/// return it
|
/// return it
|
||||||
pub fn unshift_child(&mut self) -> Option<Element> {
|
pub fn unshift_child(&mut self) -> Option<Element> {
|
||||||
while self.children.len() > 0 {
|
while self.children.is_empty() {
|
||||||
if let Some(el) = self.children.remove(0).into_element() {
|
if let Some(el) = self.children.remove(0).into_element() {
|
||||||
return Some(el);
|
return Some(el);
|
||||||
}
|
}
|
||||||
|
|
|
@ -201,8 +201,8 @@ impl From<ElementBuilder> for Node {
|
||||||
impl PartialEq for Node {
|
impl PartialEq for Node {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
match (self, other) {
|
match (self, other) {
|
||||||
(&Node::Element(ref elem1), &Node::Element(ref elem2)) => elem1 == elem2,
|
(Node::Element(elem1), Node::Element(elem2)) => elem1 == elem2,
|
||||||
(&Node::Text(ref text1), &Node::Text(ref text2)) => text1 == text2,
|
(Node::Text(text1), Node::Text(text2)) => text1 == text2,
|
||||||
_ => false,
|
_ => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,12 @@ pub struct TreeBuilder {
|
||||||
pub root: Option<Element>,
|
pub root: Option<Element>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for TreeBuilder {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl TreeBuilder {
|
impl TreeBuilder {
|
||||||
/// Create a new one
|
/// Create a new one
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
|
@ -110,27 +116,20 @@ impl TreeBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
RawEvent::Attribute(_, (prefix, name), value) => {
|
RawEvent::Attribute(_, (prefix, name), value) => {
|
||||||
self.next_tag
|
if let Some((_, _, ref mut prefixes, ref mut attrs)) = self.next_tag.as_mut() {
|
||||||
.as_mut()
|
match (prefix, name) {
|
||||||
.map(
|
(None, xmlns) if xmlns == "xmlns" => prefixes.insert(None, value),
|
||||||
|(_, _, ref mut prefixes, ref mut attrs)| match (prefix, name) {
|
(Some(xmlns), prefix) if xmlns.as_str() == "xmlns" => {
|
||||||
(None, xmlns) if xmlns == "xmlns" => {
|
prefixes.insert(Some(prefix.as_str().to_owned()), value);
|
||||||
prefixes.insert(None, value);
|
}
|
||||||
}
|
(Some(prefix), name) => {
|
||||||
(Some(xmlns), prefix) if xmlns.as_str() == "xmlns" => {
|
attrs.insert(format!("{}:{}", prefix, name), value.as_str().to_owned());
|
||||||
prefixes.insert(Some(prefix.as_str().to_owned()), value);
|
}
|
||||||
}
|
(None, name) => {
|
||||||
(Some(prefix), name) => {
|
attrs.insert(name.as_str().to_owned(), value.as_str().to_owned());
|
||||||
attrs.insert(
|
}
|
||||||
format!("{}:{}", prefix, name),
|
}
|
||||||
value.as_str().to_owned(),
|
}
|
||||||
);
|
|
||||||
}
|
|
||||||
(None, name) => {
|
|
||||||
attrs.insert(name.as_str().to_owned(), value.as_str().to_owned());
|
|
||||||
}
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RawEvent::ElementHeadClose(_) => {
|
RawEvent::ElementHeadClose(_) => {
|
||||||
|
|
Loading…
Reference in a new issue