Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: make deriving Debug optional #367

Closed
wants to merge 2 commits into from
Closed

Conversation

TheVova
Copy link

@TheVova TheVova commented Sep 10, 2020

addresses #334 by allowing users to opt-out of having prost derive Debug for its structs.

  1. prost_build::Config gains a no_derive_dbg(bool) method for users to use. this inserts a #[prost(no_dbg)] attribute on the generated struct.
  2. prost-derive checks for that attribute and skips deriving Debug if it is present.
  3. The bound on Message change from Debug + Send + Sync to just Send + Sync.
    The default behavior is opt-out, so it breaks nothing for current users.
    WIP because still need to adjust docs, but wanted to see if this is acceptable.

@TheVova TheVova marked this pull request as draft September 10, 2020 10:11
@TheVova
Copy link
Author

TheVova commented Sep 10, 2020

Ok, so this breaks some tests atm because of the hidden assumption that Message implies Debug, which probably means it will break some user code that relies on this property. One solution would be to restore the Debug bound to Message and just rely that every type is gonna have either prost-debug, #[derive(Debug)] or a manual impl Debug done for it.
alternatively, could also make this PR more granular and apply to single messages rather than all...
this then still doesnt allow deriving Message with structs that dont implement debug rather than having a custom debug impl...

@cbeck88
Copy link
Contributor

cbeck88 commented Mar 6, 2021

fwiw:

if this were coupled with a version bump to 0.8 it seems not unreasonable to tell users, there is a breaking change now deriving message does not also derive debug. it is very easy for users to adapt to the change, they just derive Debug as well as Message if they need it. that is the most intuitive behavior anyways and seems like the best place to end up. ofc that's just my 2 cents

@AlJohri
Copy link

AlJohri commented Jul 25, 2023

related: #493 (this PR also makes debug configurable)

@caspermeijn
Copy link
Collaborator

I think this has been fixed in main branch in the mean time.

If this comment helps you, please consider updating the crate documentation to make these features more findable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants