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)]`
6 #![feature(rustc_private)]
8 extern crate rustc_macros;
9 extern crate rustc_serialize;
11 use rustc_macros::{Decodable, Encodable};
12 use rustc_serialize::json;
13 use rustc_serialize::{Decodable, Encodable};
14 use std::cell::{Cell, RefCell};
16 #[derive(Encodable, Decodable)]
21 #[derive(Encodable, Decodable)]
28 let obj = B { foo: Cell::new(true), bar: RefCell::new(A { baz: 2 }) };
29 let s = json::encode(&obj).unwrap();
30 let obj2: B = json::decode(&s);
31 assert_eq!(obj.foo.get(), obj2.foo.get());
32 assert_eq!(obj.bar.borrow().baz, obj2.bar.borrow().baz);