You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.
@dtolnay the deny_unknown_fields is by default false, and can only be turned on by setting the attribute, so it should allow unknown fields, for example in Request the field m is ignored by default.
but for Request2 is throwing error, instead of ignoring the field m.
struct Request2; is not an empty struct, it is a unit struct. The field m isn't the issue, it's that the YAML contains a map and unit structs are not represented as maps. This is consistent with how struct Request(); (a tuple struct) would also not be valid to deserialize from a map.
An empty struct (braced struct with no fields) would be written struct Request2 {} and will deserialize from a map, ignore unknown field unless annotated serde(deny_unknown_fields).
The behavior of serde_yaml here matches the behavior of serde_json, neither {} nor {"m":null} is valid to deserialize as a unit struct in JSON either.
deny_unknown_fields on empty struct seems broken:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=408b3e98e302aae032a799b3cf9335d8
possibly similar to #304
The text was updated successfully, but these errors were encountered: