diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2017-10-28 02:16:08 +0200 |
---|---|---|
committer | Markus Unterwaditzer <markus@unterwaditzer.net> | 2017-10-28 02:16:08 +0200 |
commit | e0b102cb4ece8748e686ea633ccb654defafe6ae (patch) | |
tree | 3a70461b677d26ae661bb20a12cae90ab30fad74 | |
parent | 8704447a9d22ab2d1d66c6b56e4f69e8caede007 (diff) |
Switch to BTreeMap (#17)
-rw-r--r-- | src/component.rs | 6 | ||||
-rw-r--r-- | src/parser.rs | 6 | ||||
-rw-r--r-- | src/property.rs | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/src/component.rs b/src/component.rs index 4c46067..2c96a4a 100644 --- a/src/component.rs +++ b/src/component.rs @@ -1,5 +1,5 @@ use std::str::FromStr; -use std::collections::HashMap; +use std::collections::BTreeMap; use property::Property; use parser::Parser; @@ -11,7 +11,7 @@ pub struct Component { pub name: String, /// The component's properties. - pub props: HashMap<String, Vec<Property>>, + pub props: BTreeMap<String, Vec<Property>>, /// The component's child- or sub-components. pub subcomponents: Vec<Component> @@ -21,7 +21,7 @@ impl Component { pub fn new<N: Into<String>>(name: N) -> Component { Component { name: name.into(), - props: HashMap::new(), + props: BTreeMap::new(), subcomponents: vec![] } } diff --git a/src/parser.rs b/src/parser.rs index 0276ec3..4943654 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use std::collections::BTreeMap; use component::Component; use property::Property; @@ -250,8 +250,8 @@ impl<'s> Parser<'s> { Ok((name, value)) } - fn consume_params(&mut self) -> HashMap<String, String> { - let mut rv: HashMap<String, String> = HashMap::new(); + fn consume_params(&mut self) -> BTreeMap<String, String> { + let mut rv: BTreeMap<String, String> = BTreeMap::new(); while self.consume_only_char(';') { match self.consume_param() { Ok((name, value)) => { rv.insert(name.to_owned(), value.to_owned()); }, diff --git a/src/property.rs b/src/property.rs index b5e567d..6fd625a 100644 --- a/src/property.rs +++ b/src/property.rs @@ -1,4 +1,4 @@ -use std::collections::HashMap; +use std::collections::BTreeMap; #[derive(Clone, Debug)] pub struct Property { @@ -6,7 +6,7 @@ pub struct Property { pub name: String, /// Parameters. - pub params: HashMap<String, String>, + pub params: BTreeMap<String, String>, /// Value as unparsed string. pub raw_value: String, @@ -24,7 +24,7 @@ impl Property { { Property { name: name.into(), - params: HashMap::new(), + params: BTreeMap::new(), raw_value: escape_chars(value.as_ref()), prop_group: None } |