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
Writing derive macro code is hard and println!("{:?}", some_var) is very helpful when debugging and trying to understand things.
There are a lot of structs in serde_derive that do not implement Debug trait, i.e. enum TagType, struct RenameRule, etc. Yes, those are somewhat internal structs, but when implementing derive macro it is necessary to work with them.
I understand that for most use-cases Debug trait on those structs is not necessary or useful. It is useful only when developing derive macros, thus i would like to propose, in my opinion, a low maintenance, backwards compatible solution to this.
Create a feature flag debug-impls. It could be named anything, i just chose name similar to clone-impls in syn crate; since serde has that as dependency and naming convention would be somewhat similar.
Then in serde_derive code we could add cfg_attr lines like so:
Writing derive macro code is hard and
println!("{:?}", some_var)
is very helpful when debugging and trying to understand things.There are a lot of structs in serde_derive that do not implement
Debug
trait, i.e. enum TagType, struct RenameRule, etc. Yes, those are somewhat internal structs, but when implementing derive macro it is necessary to work with them.I understand that for most use-cases Debug trait on those structs is not necessary or useful. It is useful only when developing derive macros, thus i would like to propose, in my opinion, a low maintenance, backwards compatible solution to this.
Create a feature flag
debug-impls
. It could be named anything, i just chose name similar to clone-impls in syn crate; since serde has that as dependency and naming convention would be somewhat similar.Then in serde_derive code we could add
cfg_attr
lines like so:or for structs that do not have anything derived:
Syntax works in both cases.
I would like to take care of this and send PRs, if they are accepted.
The text was updated successfully, but these errors were encountered: