]>
Commit | Line | Data |
---|---|---|
416331ca XL |
1 | // run-pass |
2 | ||
0bf4aa26 XL |
3 | #![allow(unused_mut)] |
4 | #![allow(unused_imports)] | |
c34b1796 | 5 | #![feature(rustc_private)] |
1a4d82fc | 6 | |
3dfed10e | 7 | extern crate rustc_macros; |
f035d41b | 8 | extern crate rustc_serialize; |
1a4d82fc | 9 | |
3dfed10e | 10 | use rustc_macros::{Decodable, Encodable}; |
f035d41b | 11 | use rustc_serialize::json; |
3dfed10e | 12 | use rustc_serialize::{Decodable, Encodable}; |
1a4d82fc | 13 | |
3dfed10e | 14 | #[derive(Encodable, Decodable, PartialEq, Debug)] |
1a4d82fc JJ |
15 | struct UnitLikeStruct; |
16 | ||
17 | pub fn main() { | |
18 | let obj = UnitLikeStruct; | |
85aaf69f | 19 | let json_str: String = json::encode(&obj).unwrap(); |
1a4d82fc | 20 | |
85aaf69f | 21 | let json_object = json::from_str(&json_str); |
1a4d82fc | 22 | let mut decoder = json::Decoder::new(json_object.unwrap()); |
5099ac24 | 23 | let mut decoded_obj: UnitLikeStruct = Decodable::decode(&mut decoder); |
1a4d82fc JJ |
24 | |
25 | assert_eq!(obj, decoded_obj); | |
26 | } |