diff options
| author | bors <bors@rust-lang.org> | 2014-05-03 10:56:57 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-05-03 10:56:57 -0700 |
| commit | 0c691df8acaf10aa3721476e5d7fafcee11b0aaa (patch) | |
| tree | 7aca9144c64039fea0aff444e13870b4be40fae7 /src/libserialize | |
| parent | bca9647cd34c78a1c7c2409fbb2c31cb2c8194d7 (diff) | |
| parent | a5be12ce7e88c1d28de1c98215991127d1e765f0 (diff) | |
| download | rust-0c691df8acaf10aa3721476e5d7fafcee11b0aaa.tar.gz rust-0c691df8acaf10aa3721476e5d7fafcee11b0aaa.zip | |
auto merge of #13773 : brson/rust/boxxy, r=alexcrichton
`box` is the way you allocate in future-rust.
Diffstat (limited to 'src/libserialize')
| -rw-r--r-- | src/libserialize/json.rs | 126 | ||||
| -rw-r--r-- | src/libserialize/serialize.rs | 2 |
2 files changed, 64 insertions, 64 deletions
diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 6e7fab21442..5c86566b2af 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -1772,7 +1772,7 @@ impl<T: Iterator<char>> Builder<T> { fn build_object(&mut self) -> Result<Json, BuilderError> { self.bump(); - let mut values = ~TreeMap::new(); + let mut values = box TreeMap::new(); while self.token != None { match self.token { @@ -2213,7 +2213,7 @@ impl<A:ToJson,B:ToJson> ToJson for (A, B) { fn to_json(&self) -> Json { match *self { (ref a, ref b) => { - List(~[a.to_json(), b.to_json()]) + List(box [a.to_json(), b.to_json()]) } } } @@ -2223,7 +2223,7 @@ impl<A:ToJson,B:ToJson,C:ToJson> ToJson for (A, B, C) { fn to_json(&self) -> Json { match *self { (ref a, ref b, ref c) => { - List(~[a.to_json(), b.to_json(), c.to_json()]) + List(box [a.to_json(), b.to_json(), c.to_json()]) } } } @@ -2243,7 +2243,7 @@ impl<A:ToJson> ToJson for TreeMap<~str, A> { for (key, value) in self.iter() { d.insert((*key).clone(), value.to_json()); } - Object(~d) + Object(box d) } } @@ -2253,7 +2253,7 @@ impl<A:ToJson> ToJson for HashMap<~str, A> { for (key, value) in self.iter() { d.insert((*key).clone(), value.to_json()); } - Object(~d) + Object(box d) } } @@ -2309,7 +2309,7 @@ mod tests { } fn mk_object(items: &[(~str, Json)]) -> Json { - let mut d = ~TreeMap::new(); + let mut d = box TreeMap::new(); for item in items.iter() { match *item { @@ -2374,10 +2374,10 @@ mod tests { ]".to_owned() ); - let long_test_list = List(~[ + let long_test_list = List(box [ Boolean(false), Null, - List(~[String("foo\nbar".to_owned()), Number(3.5)])]); + List(box [String("foo\nbar".to_owned()), Number(3.5)])]); assert_eq!(long_test_list.to_str(), "[false,null,[\"foo\\nbar\",3.5]]".to_owned()); @@ -2413,7 +2413,7 @@ mod tests { ); let complex_obj = mk_object([ - ("b".to_owned(), List(~[ + ("b".to_owned(), List(box [ mk_object([("c".to_owned(), String("\x0c\r".to_owned()))]), mk_object([("d".to_owned(), String("".to_owned()))]) ])) @@ -2445,7 +2445,7 @@ mod tests { let a = mk_object([ ("a".to_owned(), Boolean(true)), - ("b".to_owned(), List(~[ + ("b".to_owned(), List(box [ mk_object([("c".to_owned(), String("\x0c\r".to_owned()))]), mk_object([("d".to_owned(), String("".to_owned()))]) ])) @@ -3115,34 +3115,34 @@ mod tests { assert_stream_equal( "{}", - ~[(ObjectStart, ~[]), (ObjectEnd, ~[])] + box [(ObjectStart, box []), (ObjectEnd, box [])] ); assert_stream_equal( "{\"a\": 3}", - ~[ - (ObjectStart, ~[]), - (NumberValue(3.0), ~[Key("a")]), - (ObjectEnd, ~[]), + box [ + (ObjectStart, box []), + (NumberValue(3.0), box [Key("a")]), + (ObjectEnd, box []), ] ); assert_stream_equal( "{ \"a\": null, \"b\" : true }", - ~[ - (ObjectStart, ~[]), - (NullValue, ~[Key("a")]), - (BooleanValue(true), ~[Key("b")]), - (ObjectEnd, ~[]), + box [ + (ObjectStart, box []), + (NullValue, box [Key("a")]), + (BooleanValue(true), box [Key("b")]), + (ObjectEnd, box []), ] ); assert_stream_equal( "{\"a\" : 1.0 ,\"b\": [ true ]}", - ~[ - (ObjectStart, ~[]), - (NumberValue(1.0), ~[Key("a")]), - (ListStart, ~[Key("b")]), - (BooleanValue(true),~[Key("b"), Index(0)]), - (ListEnd, ~[Key("b")]), - (ObjectEnd, ~[]), + box [ + (ObjectStart, box []), + (NumberValue(1.0), box [Key("a")]), + (ListStart, box [Key("b")]), + (BooleanValue(true),box [Key("b"), Index(0)]), + (ListEnd, box [Key("b")]), + (ObjectEnd, box []), ] ); assert_stream_equal( @@ -3174,70 +3174,70 @@ mod tests { fn test_read_list_streaming() { assert_stream_equal( "[]", - ~[ - (ListStart, ~[]), - (ListEnd, ~[]), + box [ + (ListStart, box []), + (ListEnd, box []), ] ); assert_stream_equal( "[ ]", - ~[ - (ListStart, ~[]), - (ListEnd, ~[]), + box [ + (ListStart, box []), + (ListEnd, box []), ] ); assert_stream_equal( "[true]", - ~[ - (ListStart, ~[]), - (BooleanValue(true), ~[Index(0)]), - (ListEnd, ~[]), + box [ + (ListStart, box []), + (BooleanValue(true), box [Index(0)]), + (ListEnd, box []), ] ); assert_stream_equal( "[ false ]", - ~[ - (ListStart, ~[]), - (BooleanValue(false), ~[Index(0)]), - (ListEnd, ~[]), + box [ + (ListStart, box []), + (BooleanValue(false), box [Index(0)]), + (ListEnd, box []), ] ); assert_stream_equal( "[null]", - ~[ - (ListStart, ~[]), - (NullValue, ~[Index(0)]), - (ListEnd, ~[]), + box [ + (ListStart, box []), + (NullValue, box [Index(0)]), + (ListEnd, box []), ] ); assert_stream_equal( "[3, 1]", - ~[ - (ListStart, ~[]), - (NumberValue(3.0), ~[Index(0)]), - (NumberValue(1.0), ~[Index(1)]), - (ListEnd, ~[]), + box [ + (ListStart, box []), + (NumberValue(3.0), box [Index(0)]), + (NumberValue(1.0), box [Index(1)]), + (ListEnd, box []), ] ); assert_stream_equal( "\n[3, 2]\n", - ~[ - (ListStart, ~[]), - (NumberValue(3.0), ~[Index(0)]), - (NumberValue(2.0), ~[Index(1)]), - (ListEnd, ~[]), + box [ + (ListStart, box []), + (NumberValue(3.0), box [Index(0)]), + (NumberValue(2.0), box [Index(1)]), + (ListEnd, box []), ] ); assert_stream_equal( "[2, [4, 1]]", - ~[ - (ListStart, ~[]), - (NumberValue(2.0), ~[Index(0)]), - (ListStart, ~[Index(1)]), - (NumberValue(4.0), ~[Index(1), Index(0)]), - (NumberValue(1.0), ~[Index(1), Index(1)]), - (ListEnd, ~[Index(1)]), - (ListEnd, ~[]), + box [ + (ListStart, box []), + (NumberValue(2.0), box [Index(0)]), + (ListStart, box [Index(1)]), + (NumberValue(4.0), box [Index(1), Index(0)]), + (NumberValue(1.0), box [Index(1), Index(1)]), + (ListEnd, box [Index(1)]), + (ListEnd, box []), ] ); diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index 9801a243efa..65f1016515f 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -399,7 +399,7 @@ impl<E, S:Encoder<E>,T:Encodable<S, E>> Encodable<S, E> for ~T { impl<E, D:Decoder<E>,T:Decodable<D, E>> Decodable<D, E> for ~T { fn decode(d: &mut D) -> Result<~T, E> { - Ok(~try!(Decodable::decode(d))) + Ok(box try!(Decodable::decode(d))) } } |
