diff options
author | Alex Crichton <alex@alexcrichton.com> | 2014-12-20 22:35:14 -0800 |
---|---|---|
committer | Alex Crichton <alex@alexcrichton.com> | 2014-12-20 22:35:30 -0800 |
commit | 95c6161dcec9cdaada7e1507c6e536eeb7623ed4 (patch) | |
tree | 92d2a790b4e5963011c980b15d5d8f2ef4d866d4 | |
parent | 1346affca989975890b3a0d906b54c10c814e156 (diff) | |
download | milf-rs-95c6161dcec9cdaada7e1507c6e536eeb7623ed4.tar.gz milf-rs-95c6161dcec9cdaada7e1507c6e536eeb7623ed4.zip |
Update to rust master
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/lib.rs | 8 | ||||
-rw-r--r-- | src/parser.rs | 10 | ||||
-rw-r--r-- | src/serialization.rs | 16 | ||||
-rw-r--r-- | src/show.rs | 4 | ||||
-rw-r--r-- | src/test/valid.rs | 4 |
6 files changed, 22 insertions, 22 deletions
@@ -1,7 +1,7 @@ [package] name = "toml" -version = "0.1.5" +version = "0.1.6" authors = ["Alex Crichton <alex@alexcrichton.com>"] license = "MIT/Apache-2.0" readme = "README.md" @@ -43,7 +43,7 @@ extern crate serialize; -use std::collections::TreeMap; +use std::collections::BTreeMap; use std::str::FromStr; use std::string; @@ -79,7 +79,7 @@ pub enum Value { pub type Array = Vec<Value>; /// Type representing a TOML table, payload of the Value::Table variant -pub type Table = TreeMap<string::String, Value>; +pub type Table = BTreeMap<string::String, Value>; impl Value { /// Tests whether this and another value have the same type. @@ -185,9 +185,9 @@ impl Value { for key in path.split('.') { match cur_value { &Value::Table(ref hm) => { - match hm.find_with(|k| key.cmp(k.as_slice())) { + match hm.get(key) { Some(v) => cur_value = v, - _ => return None + None => return None } }, &Value::Array(ref v) => { diff --git a/src/parser.rs b/src/parser.rs index 9143673..750cfec 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1,5 +1,5 @@ use std::char; -use std::collections::TreeMap; +use std::collections::BTreeMap; use std::error::Error; use std::num::FromStrRadix; use std::str; @@ -140,7 +140,7 @@ impl<'a> Parser<'a> { /// If an error occurs, the `errors` field of this parser can be consulted /// to determine the cause of the parse failure. pub fn parse(&mut self) -> Option<TomlTable> { - let mut ret = TreeMap::new(); + let mut ret = BTreeMap::new(); loop { self.ws(); match self.cur.clone().next() { @@ -179,7 +179,7 @@ impl<'a> Parser<'a> { } // Build the section table - let mut table = TreeMap::new(); + let mut table = BTreeMap::new(); if !self.values(&mut table) { return None } if array { self.insert_array(&mut ret, section, Table(table), start) @@ -677,7 +677,7 @@ impl<'a> Parser<'a> { } // Initialize an empty table as part of this sub-key - tmp.insert(part.clone(), Table(TreeMap::new())); + tmp.insert(part.clone(), Table(BTreeMap::new())); match *tmp.get_mut(&part).unwrap() { Table(ref mut inner) => cur = inner, _ => unreachable!(), @@ -695,7 +695,7 @@ impl<'a> Parser<'a> { let key = key.to_string(); let mut added = false; if !into.contains_key(&key) { - into.insert(key.clone(), Table(TreeMap::new())); + into.insert(key.clone(), Table(BTreeMap::new())); added = true; } match into.get_mut(&key) { diff --git a/src/serialization.rs b/src/serialization.rs index 9dc4835..a0eb5c3 100644 --- a/src/serialization.rs +++ b/src/serialization.rs @@ -1,4 +1,4 @@ -use std::collections::TreeMap; +use std::collections::BTreeMap; use std::mem; use std::fmt; use std::error::Error as StdError; @@ -136,7 +136,7 @@ pub fn encode_str<T: serialize::Encodable<Encoder, Error>>(t: &T) -> String { impl Encoder { /// Constructs a new encoder which will emit to the given output stream. pub fn new() -> Encoder { - Encoder { state: Start, toml: TreeMap::new() } + Encoder { state: Start, toml: BTreeMap::new() } } fn emit_value(&mut self, v: Value) -> Result<(), Error> { @@ -812,7 +812,7 @@ impl StdError for Error { #[cfg(test)] mod tests { - use std::collections::{TreeMap, HashSet}; + use std::collections::{BTreeMap, HashSet}; use serialize::{Encodable, Decodable}; use super::{Encoder, Decoder, DecodeError}; @@ -831,7 +831,7 @@ mod tests { }) ); macro_rules! map( ($($k:ident: $v:expr),*) => ({ - let mut _m = TreeMap::new(); + let mut _m = BTreeMap::new(); $(_m.insert(stringify!($k).to_string(), $v);)* _m }) ); @@ -855,7 +855,7 @@ mod tests { assert_eq!(encode!(v), map! { a_b: Integer(2) }); assert_eq!(v, decode!(Table(encode!(v)))); - let mut m = TreeMap::new(); + let mut m = BTreeMap::new(); m.insert("a-b".to_string(), Integer(2)); assert_eq!(v, decode!(Table(encode!(v)))); } @@ -980,13 +980,13 @@ mod tests { fn hashmap() { #[deriving(Encodable, Decodable, PartialEq, Show)] struct Foo { - map: TreeMap<String, int>, + map: BTreeMap<String, int>, set: HashSet<char>, } let v = Foo { map: { - let mut m = TreeMap::new(); + let mut m = BTreeMap::new(); m.insert("foo".to_string(), 10); m.insert("bar".to_string(), 4); m @@ -1180,7 +1180,7 @@ mod tests { #[test] fn unused_fields4() { #[deriving(Encodable, Decodable, PartialEq, Show)] - struct Foo { a: TreeMap<String, String> } + struct Foo { a: BTreeMap<String, String> } let v = Foo { a: map! { a: "foo".to_string() } }; let mut d = Decoder::new(Table(map! { diff --git a/src/show.rs b/src/show.rs index 5878eb6..487c62a 100644 --- a/src/show.rs +++ b/src/show.rs @@ -96,10 +96,10 @@ impl<'a, 'b> Printer<'a, 'b> { mod tests { use Value; use Value::{String, Integer, Float, Boolean, Datetime, Array, Table}; - use std::collections::TreeMap; + use std::collections::BTreeMap; macro_rules! map( ($($k:expr: $v:expr),*) => ({ - let mut _m = TreeMap::new(); + let mut _m = BTreeMap::new(); $(_m.insert($k.to_string(), $v);)* _m }) ); diff --git a/src/test/valid.rs b/src/test/valid.rs index e38cf5b..205e9e6 100644 --- a/src/test/valid.rs +++ b/src/test/valid.rs @@ -1,7 +1,7 @@ extern crate serialize; use std::num::strconv; -use std::collections::TreeMap; +use std::collections::BTreeMap; use self::serialize::json::{mod, Json}; use {Parser, Value}; @@ -9,7 +9,7 @@ use Value::{Table, Integer, Float, Boolean, Datetime, Array}; fn to_json(toml: Value) -> Json { fn doit(s: &str, json: Json) -> Json { - let mut map = TreeMap::new(); + let mut map = BTreeMap::new(); map.insert("type".to_string(), Json::String(s.to_string())); map.insert("value".to_string(), json); Json::Object(map) |