diff options
author | Valerii Hiora <valerii.hiora@gmail.com> | 2014-06-27 17:28:55 +0300 |
---|---|---|
committer | Valerii Hiora <valerii.hiora@gmail.com> | 2014-06-27 17:28:55 +0300 |
commit | 13cc8a9201fd8ed5d80ea57a08104aa79a5e757e (patch) | |
tree | f1c6fc9eaad26cdacf9a50e6b96f9a11bfb24765 | |
parent | 2047fa3bc910ad3a2eec3f23309cd60064a63a7a (diff) | |
download | milf-rs-13cc8a9201fd8ed5d80ea57a08104aa79a5e757e.tar.gz milf-rs-13cc8a9201fd8ed5d80ea57a08104aa79a5e757e.zip |
Fixed tests, merged lookup functions
-rw-r--r-- | src/toml.rs | 19 |
1 files changed, 4 insertions, 15 deletions
diff --git a/src/toml.rs b/src/toml.rs index 3223c91..440da6a 100644 --- a/src/toml.rs +++ b/src/toml.rs @@ -55,7 +55,7 @@ pub use serialization::{InvalidMapKeyLocation, InvalidMapKeyType}; mod parser; mod show; mod serialization; - +#[cfg(test)]mod test; /// Representation of a TOML value. #[deriving(PartialEq, Clone)] #[allow(missing_doc)] @@ -172,18 +172,8 @@ impl Value { /// assert_eq!(no_bar.is_none(), true); /// ``` pub fn lookup<'a>(&'a self, path: &'a str) -> Option<&'a Value> { - Value::lookup_path(self, path.split('.')) - } - - // Performs actual traverse starting with value - // - // For arrays tries to convert key to uint and retrieve - // corresponding element - fn lookup_path<'a, I:Iterator<&'a str>>(value: &'a Value, - components: I) -> Option<&'a Value> { - let mut cur_value: &'a Value = value; - let mut iter = components; - for key in iter { + let mut cur_value = self; + for key in path.split('.') { match cur_value { &Table(ref hm) => { match hm.find_equiv(&key) { @@ -212,9 +202,8 @@ impl FromStr for Value { } } - #[cfg(test)] -mod test { +mod tests { use super::Value; #[test] |