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
#[serde(flatten)] is being written over and over again, considering that if there are a lot of such public structs, if we forget to write the field attr somewhere, it will expose this unintended field p to the user. This is hard to discover unless we write tests for each public struct.
So if we support flatten as a container attribute, we can get rid of that worry
This is not something that can be implemented in most formats. By the time any code in P's Serialize impl runs, the field name "p" would already have been emitted. Similarly P's Deserialize impl would only come into play if a "p" field is present.
Let's say I have a internal private struct
struct P
, and I also have multiple public structs(All these structs are
#[derive(Deserialize)]
, I omitted it from the code below)Since
P
is a private struct, I want to hide the fieldp
from the deserialization of these public structs, so we have to write the code in this way#[serde(flatten)]
is being written over and over again, considering that if there are a lot of such public structs, if we forget to write the field attr somewhere, it will expose this unintended fieldp
to the user. This is hard to discover unless we write tests for each public struct.So if we support
flatten
as a container attribute, we can get rid of that worryThe text was updated successfully, but these errors were encountered: