|
@seanmonstar | |||||
|
How I yearn for some attributes to customize deriving `Debug`. For example:
#[derive(Debug)]
struct MissingCookie {
#[debug::skip]
_priv: (),
}
|
||||||
|
||||||
|
Doug Tangren 🐑
@softprops
|
16. sij |
|
What is this pattern of embedding a private unit member in pub structs about? I vaugely recall this had to do with API stability but is that still relevant with the non_exhaistive attribute that stabilized in 1.40? blog.rust-lang.org/2019/12/19/Rus…
|
||
|
|
||
|
Sean McArthur
@seanmonstar
|
16. sij |
|
Yes, it's for stability. By not exposing publicly the layout, you can add new fields without breaking users who were constructing it without a function.
I haven't toyed with non_exhaustive, since it's so new!
|
||
|
|
||
|
Thomas Eizinger
@oetzn
|
16. sij |
|
If you are fine with serde as a dependency there is `SerDebug` which allows you to derive Debug with the power of serde.
|
||
|
|
||
|
Thomas Eizinger
@oetzn
|
16. sij |
|
I would choose native customization over that any day though.
|
||
|
|
||