From 39d77b6d79dfbba6923f1529f63a3b6117bb6772 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 18 Dec 2015 16:29:07 -0800 Subject: When decoding maps, leave fields that weren't processed Fixes an XXX --- src/encoder/rustc_serialize.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/encoder') diff --git a/src/encoder/rustc_serialize.rs b/src/encoder/rustc_serialize.rs index ab5e90f..7f1db87 100644 --- a/src/encoder/rustc_serialize.rs +++ b/src/encoder/rustc_serialize.rs @@ -639,6 +639,33 @@ mod tests { }))); } + #[test] + fn unused_fields8() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { a: BTreeMap } + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Bar { a: isize } + + let v = Foo { a: map! { a, Bar { a: 2 } } }; + let mut d = Decoder::new(Table(map! { + a, Table(map! { + a, Table(map! { + a, Integer(2), + b, Integer(2) + }) + }) + })); + assert_eq!(v, Decodable::decode(&mut d).unwrap()); + + assert_eq!(d.toml, Some(Table(map! { + a, Table(map! { + a, Table(map! { + b, Integer(2) + }) + }) + }))); + } + #[test] fn empty_arrays() { #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] -- cgit v1.2.3