Use a BTreeMap<String, String> instead of a Vec<Attribute> to store attributes
This way we don't need to reimplement PartialEq for Element. It's also way easier to get an attribute by name as we don't need to iterate over every attribute to see if it exists. The only side effect is that now, in the Debug output, attributes are automatically sorted by names instead of being sorted by insertion order. Fixes #4
This commit is contained in:
parent
2aef4aacb8
commit
f87e2442d4
4 changed files with 29 additions and 95 deletions
|
|
@ -7,7 +7,7 @@ use xml::writer::EventWriter;
|
|||
|
||||
use element::Element;
|
||||
|
||||
const TEST_STRING: &'static str = r#"<?xml version="1.0" encoding="utf-8"?><root xmlns="root_ns" xml:lang="en" a="b">meow<child c="d" /><child xmlns="child_ns" d="e" xml:lang="fr" />nya</root>"#;
|
||||
const TEST_STRING: &'static str = r#"<?xml version="1.0" encoding="utf-8"?><root xmlns="root_ns" a="b" xml:lang="en">meow<child c="d" /><child xmlns="child_ns" d="e" xml:lang="fr" />nya</root>"#;
|
||||
|
||||
fn build_test_tree() -> Element {
|
||||
let mut root = Element::builder("root")
|
||||
|
|
|
|||
Loading…
Reference in a new issue