From 090040bf4037a094e50b03d79e4baf5cd89c912b Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Mon, 5 May 2014 18:56:44 -0700 Subject: librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, except for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change] --- src/libserialize/json.rs | 15 +++++++-------- src/libserialize/serialize.rs | 6 +++--- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'src/libserialize') diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 5c86566b2af..d1fe04bccf8 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -113,7 +113,7 @@ pub struct MyStruct { impl ToJson for MyStruct { fn to_json( &self ) -> json::Json { - let mut d = ~TreeMap::new(); + let mut d = box TreeMap::new(); d.insert("attr1".to_owned(), self.attr1.to_json()); d.insert("attr2".to_owned(), self.attr2.to_json()); json::Object(d) @@ -206,7 +206,7 @@ pub struct TestStruct1 { impl ToJson for TestStruct1 { fn to_json( &self ) -> json::Json { - let mut d = ~TreeMap::new(); + let mut d = box TreeMap::new(); d.insert("data_int".to_owned(), self.data_int.to_json()); d.insert("data_str".to_owned(), self.data_str.to_json()); d.insert("data_vector".to_owned(), self.data_vector.to_json()); @@ -232,21 +232,20 @@ fn main() { */ -use collections::HashMap; use std::char; use std::f64; +use std::fmt; use std::io::MemWriter; use std::io; +use std::mem::swap; use std::num; -use std::str; use std::str::ScalarValue; +use std::str; use std::strbuf::StrBuf; -use std::fmt; use std::vec::Vec; -use std::mem::swap; use Encodable; -use collections::TreeMap; +use collections::{HashMap, TreeMap}; /// Represents a json value #[deriving(Clone, Eq)] @@ -255,7 +254,7 @@ pub enum Json { String(~str), Boolean(bool), List(List), - Object(~Object), + Object(Box), Null, } diff --git a/src/libserialize/serialize.rs b/src/libserialize/serialize.rs index 65f1016515f..9d68705fca7 100644 --- a/src/libserialize/serialize.rs +++ b/src/libserialize/serialize.rs @@ -391,14 +391,14 @@ impl<'a, E, S:Encoder,T:Encodable> Encodable for &'a T { } } -impl,T:Encodable> Encodable for ~T { +impl,T:Encodable> Encodable for Box { fn encode(&self, s: &mut S) -> Result<(), E> { (**self).encode(s) } } -impl,T:Decodable> Decodable for ~T { - fn decode(d: &mut D) -> Result<~T, E> { +impl,T:Decodable> Decodable for Box { + fn decode(d: &mut D) -> Result, E> { Ok(box try!(Decodable::decode(d))) } } -- cgit 1.4.1-3-g733a5