Twitter | Pretraživanje | |
Sean McArthur
How I yearn for some attributes to customize deriving `Debug`. For example: #[derive(Debug)] struct MissingCookie { #[debug::skip] _priv: (), }
Reply Retweet Označi sa "sviđa mi se" More
Doug Tangren 🐑 16. sij
Odgovor korisniku/ci @seanmonstar
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?
Reply Retweet Označi sa "sviđa mi se"
Sean McArthur 16. sij
Odgovor korisniku/ci @softprops
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!
Reply Retweet Označi sa "sviđa mi se"
Thomas Eizinger 16. sij
Odgovor korisniku/ci @seanmonstar
If you are fine with serde as a dependency there is `SerDebug` which allows you to derive Debug with the power of serde.
Reply Retweet Označi sa "sviđa mi se"
Thomas Eizinger 16. sij
Odgovor korisniku/ci @seanmonstar
I would choose native customization over that any day though.
Reply Retweet Označi sa "sviđa mi se"