diff --git a/src/errors.rs b/src/errors.rs index 9952b6b..0582a3b 100644 --- a/src/errors.rs +++ b/src/errors.rs @@ -1,6 +1,11 @@ use thiserror::Error; +/* use xml; - +// this is redundant, cargo clippy suggested to remove it + = note: `#[warn(clippy::single_component_path_imports)]` on by default + = help: for further information visit + https://rust-lang.github.io/rust-clippy/master/index.html#single_component_path_imports +*/ #[derive(Debug, Error)] pub enum TreexmlError { #[error("Element not found: '{t}'")] diff --git a/tests/read.rs b/tests/read.rs index a0284d6..b17cd34 100644 --- a/tests/read.rs +++ b/tests/read.rs @@ -1,9 +1,7 @@ extern crate treexml; mod read { - mod document { - use treexml::{Document, XmlVersion}; #[test] @@ -37,7 +35,6 @@ mod read { } mod tags { - use treexml::Document; #[test] @@ -102,7 +99,7 @@ mod read { let doc = Document::parse(doc_raw.as_bytes()).unwrap(); let root = doc.root.unwrap(); - assert_eq!(root.find_child(|t| t.name == "child"), None); + assert_eq!(root.find_child(|t| t.name == "child".to_owned()), None); } #[test] @@ -119,7 +116,10 @@ mod read { let mut child = Element::new("child"); child.attributes.insert("attr_a".to_owned(), "1".to_owned()); - assert_eq!(root.find_child(|t| t.name == "child"), Some(&child)); + assert_eq!( + root.find_child(|t| t.name == "child".to_owned()), + Some(&child) + ); } #[test] @@ -137,7 +137,10 @@ mod read { let mut child = Element::new("child"); child.attributes.insert("attr_a".to_owned(), "1".to_owned()); - assert_eq!(root.find_child(|t| t.name == "child"), Some(&child)); + assert_eq!( + root.find_child(|t| t.name == "child".to_owned()), + Some(&child) + ); } #[test] @@ -152,7 +155,9 @@ mod read { let mut root = doc.root.unwrap(); { - let child = root.find_child_mut(|t| t.name == "child").unwrap(); + let child = root + .find_child_mut(|t| t.name == "child".to_owned()) + .unwrap(); let attr_a = child.attributes.get_mut(&"attr_a".to_owned()).unwrap(); *attr_a = "2".to_owned(); } @@ -160,7 +165,10 @@ mod read { let mut child = Element::new("child"); child.attributes.insert("attr_a".to_owned(), "2".to_owned()); - assert_eq!(root.find_child(|t| t.name == "child"), Some(&child)); + assert_eq!( + root.find_child(|t| t.name == "child".to_owned()), + Some(&child) + ); } #[test] @@ -180,7 +188,9 @@ mod read { ch1.text = Some("1".to_owned()); ch2.text = Some("2".to_owned()); - let children: Vec<&Element> = root.filter_children(|t| t.name == "child").collect(); + let children: Vec<&Element> = root + .filter_children(|t| t.name == "child".to_owned()) + .collect(); let children_ref = vec![&ch1, &ch2]; assert_eq!(children, children_ref); @@ -199,8 +209,9 @@ mod read { let mut root = doc.root.unwrap(); { - let mut children: Vec<&mut Element> = - root.filter_children_mut(|t| t.name == "child").collect(); + let mut children: Vec<&mut Element> = root + .filter_children_mut(|t| t.name == "child".to_owned()) + .collect(); children[0].text = Some("4".to_owned()); children[1].text = Some("5".to_owned()); } @@ -210,7 +221,9 @@ mod read { ch1.text = Some("4".to_owned()); ch2.text = Some("5".to_owned()); - let children: Vec<&Element> = root.filter_children(|t| t.name == "child").collect(); + let children: Vec<&Element> = root + .filter_children(|t| t.name == "child".to_owned()) + .collect(); let children_ref = vec![&ch1, &ch2]; assert_eq!(children, children_ref); @@ -271,7 +284,6 @@ mod read { } mod cdata { - use treexml::Document; #[test] @@ -320,7 +332,6 @@ mod read { } mod complete { - use treexml::{Document, Element, XmlVersion}; #[test] diff --git a/tests/readme.rs b/tests/readme.rs index 24960a1..67281f0 100644 --- a/tests/readme.rs +++ b/tests/readme.rs @@ -1,8 +1,8 @@ extern crate treexml; mod readme { - use treexml::{Document, ElementBuilder as E}; + #[test] fn read() { let doc_raw = r#" @@ -16,7 +16,10 @@ mod readme { let doc = Document::parse(doc_raw.as_bytes()).unwrap(); let root = doc.root.unwrap(); - let fruit = root.find_child(|tag| tag.name == "fruit").unwrap().clone(); + let fruit = root + .find_child(|tag| tag.name == "fruit".to_owned()) + .unwrap() + .clone(); println!("{} [{:?}] = {:?}", fruit.name, fruit.attributes, fruit.text,); } diff --git a/tests/write.rs b/tests/write.rs index 7b8fe58..f575bc8 100644 --- a/tests/write.rs +++ b/tests/write.rs @@ -1,9 +1,7 @@ extern crate treexml; mod write { - mod document { - use treexml::{Document, Element}; #[test] @@ -49,7 +47,6 @@ mod write { } mod element { - use treexml::{Document, Element}; #[test] @@ -71,7 +68,6 @@ mod write { } mod contents { - use treexml::{Document, Element}; #[test] @@ -112,7 +108,6 @@ mod write { } mod cdata { - use treexml::{Document, Element}; #[test]