diff options
author | Alex Crichton <alex@alexcrichton.com> | 2015-12-18 16:29:07 -0800 |
---|---|---|
committer | Alex Crichton <alex@alexcrichton.com> | 2015-12-18 16:29:07 -0800 |
commit | 39d77b6d79dfbba6923f1529f63a3b6117bb6772 (patch) | |
tree | 45f35359823a1c55fbd88b0f6b5bc7945d906c2c /src/encoder | |
parent | 4987b47a92bc32aa579532959e80b45ae6e28da5 (diff) | |
download | milf-rs-39d77b6d79dfbba6923f1529f63a3b6117bb6772.tar.gz milf-rs-39d77b6d79dfbba6923f1529f63a3b6117bb6772.zip |
When decoding maps, leave fields that weren't processed
Fixes an XXX
Diffstat (limited to 'src/encoder')
-rw-r--r-- | src/encoder/rustc_serialize.rs | 27 |
1 files changed, 27 insertions, 0 deletions
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 @@ -640,6 +640,33 @@ mod tests { } #[test] + fn unused_fields8() { + #[derive(RustcEncodable, RustcDecodable, PartialEq, Debug)] + struct Foo { a: BTreeMap<String, Bar> } + #[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)] struct Foo { a: Vec<Bar> } |