Removed unnecessary Box
This commit is contained in:
parent
4c65a86571
commit
1e55dce0e4
1 changed files with 7 additions and 7 deletions
|
@ -246,7 +246,7 @@ pub enum Json {
|
||||||
String(String),
|
String(String),
|
||||||
Boolean(bool),
|
Boolean(bool),
|
||||||
List(List),
|
List(List),
|
||||||
Object(Box<Object>),
|
Object(Object),
|
||||||
Null,
|
Null,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -888,7 +888,7 @@ impl Json {
|
||||||
/// Returns None otherwise.
|
/// Returns None otherwise.
|
||||||
pub fn as_object<'a>(&'a self) -> Option<&'a Object> {
|
pub fn as_object<'a>(&'a self) -> Option<&'a Object> {
|
||||||
match self {
|
match self {
|
||||||
&Object(ref map) => Some(&**map),
|
&Object(ref map) => Some(map),
|
||||||
_ => None
|
_ => None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1720,7 +1720,7 @@ impl<T: Iterator<char>> Builder<T> {
|
||||||
fn build_object(&mut self) -> Result<Json, BuilderError> {
|
fn build_object(&mut self) -> Result<Json, BuilderError> {
|
||||||
self.bump();
|
self.bump();
|
||||||
|
|
||||||
let mut values = box TreeMap::new();
|
let mut values = TreeMap::new();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
match self.token {
|
match self.token {
|
||||||
|
@ -2117,7 +2117,7 @@ impl<A: ToJson> ToJson for TreeMap<String, A> {
|
||||||
for (key, value) in self.iter() {
|
for (key, value) in self.iter() {
|
||||||
d.insert((*key).clone(), value.to_json());
|
d.insert((*key).clone(), value.to_json());
|
||||||
}
|
}
|
||||||
Object(box d)
|
Object(d)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2127,7 +2127,7 @@ impl<A: ToJson> ToJson for HashMap<String, A> {
|
||||||
for (key, value) in self.iter() {
|
for (key, value) in self.iter() {
|
||||||
d.insert((*key).clone(), value.to_json());
|
d.insert((*key).clone(), value.to_json());
|
||||||
}
|
}
|
||||||
Object(box d)
|
Object(d)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2185,7 +2185,7 @@ mod tests {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn mk_object(items: &[(String, Json)]) -> Json {
|
fn mk_object(items: &[(String, Json)]) -> Json {
|
||||||
let mut d = box TreeMap::new();
|
let mut d = TreeMap::new();
|
||||||
|
|
||||||
for item in items.iter() {
|
for item in items.iter() {
|
||||||
match *item {
|
match *item {
|
||||||
|
@ -3252,7 +3252,7 @@ mod tests {
|
||||||
let mut tree_map = TreeMap::new();
|
let mut tree_map = TreeMap::new();
|
||||||
tree_map.insert("a".to_string(), Number(1.0_f64));
|
tree_map.insert("a".to_string(), Number(1.0_f64));
|
||||||
tree_map.insert("b".to_string(), Number(2.0_f64));
|
tree_map.insert("b".to_string(), Number(2.0_f64));
|
||||||
Object(box tree_map)
|
Object(tree_map)
|
||||||
};
|
};
|
||||||
|
|
||||||
assert_eq!(list2.to_json(), list2);
|
assert_eq!(list2.to_json(), list2);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue