Replace TreeMap with BTreeMap in the serde2

This commit is contained in:
Thomas Bahn
2014-12-23 18:33:37 +01:00
parent 7fa62b6212
commit 512a54e983
6 changed files with 27 additions and 27 deletions
+7 -7
View File
@@ -8,8 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use std::collections::TreeMap;
use std::str::StrAllocating;
use std::collections::BTreeMap;
use ser::{mod, Serialize};
use json::value::{mod, Value};
@@ -46,12 +46,12 @@ impl ArrayBuilder {
}
pub struct ObjectBuilder {
object: TreeMap<String, Value>,
object: BTreeMap<String, Value>,
}
impl ObjectBuilder {
pub fn new() -> ObjectBuilder {
ObjectBuilder { object: TreeMap::new() }
ObjectBuilder { object: BTreeMap::new() }
}
pub fn unwrap(self) -> Value {
@@ -78,7 +78,7 @@ impl ObjectBuilder {
#[cfg(test)]
mod tests {
use std::collections::TreeMap;
use std::collections::BTreeMap;
use json::value::Value;
use super::{ArrayBuilder, ObjectBuilder};
@@ -107,7 +107,7 @@ mod tests {
.insert("b".to_string(), 2i))
.unwrap();
let mut map = TreeMap::new();
let mut map = BTreeMap::new();
map.insert("a".to_string(), Value::I64(1));
map.insert("b".to_string(), Value::I64(2));
assert_eq!(value, Value::Array(vec!(Value::Object(map))));
@@ -116,14 +116,14 @@ mod tests {
#[test]
fn test_object_builder() {
let value = ObjectBuilder::new().unwrap();
assert_eq!(value, Value::Object(TreeMap::new()));
assert_eq!(value, Value::Object(BTreeMap::new()));
let value = ObjectBuilder::new()
.insert("a".to_string(), 1i)
.insert("b".to_string(), 2i)
.unwrap();
let mut map = TreeMap::new();
let mut map = BTreeMap::new();
map.insert("a".to_string(), Value::I64(1));
map.insert("b".to_string(), Value::I64(2));
assert_eq!(value, Value::Object(map));