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
I am trying to write a serve deserializer for an (in-progress) language that omits default values from struct serialization.
This is not a problem for fields like strings, numbers, booleans, lists and maps, because I can use the well-defined default of 0, false or empty. That said, I found no way to ask serde to default the values for structs/tuples and enums in the presence of missing keys.
The things I tried so far:
Recursively initializing struct/tuple fields to their primitive types' default values. This works, but does not respect any #[serde(default) or rust-level default values.
Asking the user to remember to include #[serde(default)] on all fields/structs. This works, but is quite tedious.
My ideal solution would be something like adding an optional visitor.visit_default() to the Visitor protocol, so that I could correctly initialize default values for this file format.
The text was updated successfully, but these errors were encountered:
I am trying to write a serve deserializer for an (in-progress) language that omits default values from struct serialization.
This is not a problem for fields like strings, numbers, booleans, lists and maps, because I can use the well-defined default of 0, false or empty. That said, I found no way to ask serde to default the values for structs/tuples and enums in the presence of missing keys.
The things I tried so far:
#[serde(default)
or rust-level default values.#[serde(default)]
on all fields/structs. This works, but is quite tedious.My ideal solution would be something like adding an optional
visitor.visit_default()
to the Visitor protocol, so that I could correctly initialize default values for this file format.The text was updated successfully, but these errors were encountered: