diff options
author | Alex Crichton <alex@alexcrichton.com> | 2016-03-11 09:20:32 -0800 |
---|---|---|
committer | Alex Crichton <alex@alexcrichton.com> | 2016-03-11 09:20:32 -0800 |
commit | 511c235d7dac0f8ef32f0a447205328152b58c82 (patch) | |
tree | bfa3a1bec133b14f97b020d5082e3e6c46616fc0 | |
parent | 3345fea3198b67153055f5f455ec5f5a2ab4b8af (diff) | |
download | milf-rs-511c235d7dac0f8ef32f0a447205328152b58c82.tar.gz milf-rs-511c235d7dac0f8ef32f0a447205328152b58c82.zip |
Fix last tests
-rw-r--r-- | src/decoder/serde.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/decoder/serde.rs b/src/decoder/serde.rs index 099a65b..91bc8ac 100644 --- a/src/decoder/serde.rs +++ b/src/decoder/serde.rs @@ -173,6 +173,19 @@ impl de::Deserializer for Decoder { Err(first_error.unwrap_or_else(|| self.err(DecodeErrorKind::NoEnumVariants))) } + + // When #[derive(Deserialize)] encounters an unknown struct field it will + // call this method (somehow), and we want to preserve all unknown struct + // fields to return them upwards (to warn about unused keys), so we override + // that here to not tamper with our own internal state. + fn deserialize_ignored_any<V>(&mut self, visitor: V) + -> Result<V::Value, Self::Error> + where V: de::Visitor + { + use serde::de::value::ValueDeserializer; + let mut d = <() as ValueDeserializer<Self::Error>>::into_deserializer(()); + d.deserialize(visitor) + } } struct VariantVisitor { |