3 #![allow(unused_imports)]
4 // This briefly tests the capability of `Cell` and `RefCell` to implement the
5 // `Encodable` and `Decodable` traits via `#[derive(Encodable, Decodable)]`
8 #![feature(rustc_private)]
10 extern crate serialize as rustc_serialize;
12 use std::cell::{Cell, RefCell};
13 use rustc_serialize::{Encodable, Decodable};
14 use rustc_serialize::json;
16 #[derive(RustcEncodable, RustcDecodable)]
21 #[derive(RustcEncodable, RustcDecodable)]
30 bar: RefCell::new( A { baz: 2 } )
32 let s = json::encode(&obj).unwrap();
33 let obj2: B = json::decode(&s).unwrap();
34 assert_eq!(obj.foo.get(), obj2.foo.get());
35 assert_eq!(obj.bar.borrow().baz, obj2.bar.borrow().baz);