Allow unexpected fields

This commit is contained in:
Alfie Fresta
2025-06-04 21:29:55 +02:00
committed by Robin Krahl
parent 432a7a26ed
commit 505df8957b
2 changed files with 7 additions and 2 deletions
+5 -1
View File
@@ -6,9 +6,13 @@
- Add support for `#[serde(skip)]` ([#14][])
- Add support for generics ([#11][])
- skip_serializing_if no longer incorrectly affects deserialization (fixes [#2][])
- No longer fails deserialising maps with unknown fields ([#19][])
[#14]: https://github.com/trussed-dev/serde-indexed/pull/14
[#2]: https://github.com/trussed-dev/serde-indexed/issues/2
[#11]: https://github.com/trussed-dev/serde-indexed/pull/11
[#14]: https://github.com/trussed-dev/serde-indexed/pull/14
[#19]: https://github.com/trussed-dev/serde-indexed/pull/19
## [v0.1.1][] (2024-04-03)
+2 -1
View File
@@ -224,7 +224,8 @@ pub fn derive_deserialize(input: TokenStream) -> TokenStream {
match __serde_indexed_internal_key {
#(#match_fields)*
_ => {
return Err(serde::de::Error::duplicate_field("inexistent field index"));
// Ignore unknown keys by consuming their value
let _ = map.next_value::<serde::de::IgnoredAny>()?;
}
}
}