aboutsummaryrefslogtreecommitdiff
path: root/src/decoder
diff options
context:
space:
mode:
Diffstat (limited to 'src/decoder')
-rw-r--r--src/decoder/serde.rs13
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 {