Update to rust master

This commit is contained in:
Alex Crichton 2014-12-20 22:35:14 -08:00
parent 1346affca9
commit 95c6161dce
6 changed files with 22 additions and 22 deletions

View file

@ -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"

View file

@ -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) => {

View file

@ -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) {

View file

@ -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! {

View file

@ -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
}) );

View file

@ -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)