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

Why would structs not derive Debug ? #71

Closed
yoanlcq opened this issue Oct 11, 2017 · 4 comments · Fixed by #75
Closed

Why would structs not derive Debug ? #71

yoanlcq opened this issue Oct 11, 2017 · 4 comments · Fixed by #75

Comments

@yoanlcq
Copy link

yoanlcq commented Oct 11, 2017

Greetings,

As far as I see it, making most structs derive at least Debug would be super convenient while not harmful. For instance, when drafting an error handler, it would be really nice to be able to format the XErrorEvent struct in a single line, but as of today I can't, and I have to log each field manually instead.

So I wonder if there's anything I'm missing and would really appreciate if this was "fixed". I would make a PR but I'd like to ensure that it's fine to do first.

@ghost
Copy link

ghost commented Oct 11, 2017

Wayy back when I started x11-rs, I figured it would be best to start with minimal derives because it's more practical to add new ones than to remove any that are unnecessary. Having Debug would definitely be nice, especially for error structs such as XErrorEvent, and I don't see any problems with it. I'd add it myself, but with my school load these days, I haven't had much time for this or any of my programming projects.

@yoanlcq
Copy link
Author

yoanlcq commented Oct 11, 2017

I'm in quite a similar situation myself, but yeah I'd still be willing to spend some time on it and make a PR then. It looks more time-consuming than actually hard, at least for Debug.

In short, I'd be in to make as many structs as possible derive Debug, Eq and PartialEq, but NOT Default, Hash, Ord, PartialOrd, Copy and Clone, as there's practically no use case for these (In particular Copy and Clone would be dishonest most of the time because of pointers etc).
Even then, these could be added later on a case-by-case basis.

@wolfiestyle
Copy link
Contributor

wolfiestyle commented Oct 18, 2017

I noticed this too, having Debug derived would by really helpful. Deriving PartialEq / Eq should be safe for any struct that doesn't contain pointers.

Could also implement Debug for XEvent, since it's basically a sum type. Just have to manually use the discriminant.

@yoanlcq
Copy link
Author

yoanlcq commented Oct 19, 2017

I'd just like to correct my earlier claim and point out that sadly, I'm not actually going to have the time to make a fork and fix this, at least not in the next few weeks.
Perhaps it's just a matter of doing a rough "find-and-replace" and then fixing tidbits but I haven't tried.

This issue was closed.
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 a pull request may close this issue.

2 participants