serde
serde copied to clipboard
`[serde(default = .. )]` in deep path
I'm not sure if it's a bug or a design.
I expect it to print consistent results in both cases. (Config { point: Point { x: MyInt(0), y: MyInt(1) } })
You are doing two different things here, which is why you get the different results. In the first case the Point struct is provided, but all fields are missing, thus they get filled by the default values on the fields, i.e., MyInt::default and MyInt::one.
In the second case the Point struct is missing and gets filled by Point::default. The derived Default implementation uses MyInt::default in both cases.
If you want to change the Default implementation of Point you need to implement it manually instead of deriving it.