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
When deriving YaDeserialize the macro requires that all member types implement the Default trait. I suppose this is to instantiate a value even when the XML document is missing that child or attribute.
As a consumer of this crate I would have to either make all fields Option, or implement Default for all of them. However I would rather that YaDeserialize would throw an error if that child or attribute is missing from the XML, and have an attribute #[yaserde(default)] for the current behaviour.
The text was updated successfully, but these errors were encountered:
With 82df2e1, how do you specify the equivalent of #[serde(default)] (i.e. use Default::default if value missing)? There is a #[yaserde(default)] but it seems to be for something different since it takes a string value.
It has been a long time since I created the relevant commit, but I believe the string can be used to specify a function name. This function will be called when the value is not provided in the XML input.
Hmm, so it does indeed. It has to be in the current scope though, I tested with setting it to Default::default() (with or without the parens) before and it gave an invalid identifier error.
When deriving
YaDeserialize
the macro requires that all member types implement theDefault
trait. I suppose this is to instantiate a value even when the XML document is missing that child or attribute.As a consumer of this crate I would have to either make all fields
Option
, or implementDefault
for all of them. However I would rather thatYaDeserialize
would throw an error if that child or attribute is missing from the XML, and have an attribute#[yaserde(default)]
for the current behaviour.The text was updated successfully, but these errors were encountered: