mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-26 15:37:55 +00:00
Replace TreeMap with BTreeMap in the serde2
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user