-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Make --derive
more flexible
#237
Conversation
Signed-off-by: Mathias Pius <[email protected]>
…enums with only simple members. Signed-off-by: Mathias Pius <[email protected]>
Fixes #231 Signed-off-by: Mathias Pius <[email protected]>
…ly enums Signed-off-by: Mathias Pius <[email protected]>
Signed-off-by: Mathias Pius <[email protected]>
Signed-off-by: Mathias Pius <[email protected]>
Signed-off-by: Mathias Pius <[email protected]>
Seem to have lost some code during a rebase, hang tight! |
Signed-off-by: Mathias Pius <[email protected]>
Signed-off-by: Mathias Pius <[email protected]>
Signed-off-by: Mathias Pius <[email protected]>
That should do it. Let me know what you think! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks great. Thanks a lot for doing this! I see nothing major implementation-wise here i disagree with. Some minor nits inlined (that are largely ignoreable).
One point on maintainability though; tests for this would be helpful. I also think this is self-contained enough that it could live inside a derive.rs
module that can be tested therein. That way the only part from this that really needs to live inside of main.rs is the loop over self.derive
that decides whether s
gets derives (and even that can possibly also be parametrised inside the derive
module by passing the s
by ref in there, but that's just a stray thought).
LMK what you think.
Co-authored-by: Eirik A <[email protected]> Signed-off-by: Mathias Pius <[email protected]>
Putting it in its own module makes a lot of sense, I avoided doing it because the rest of the project seemed to favor localized code over modularization. I'll try and extract it and see how testability can be written into it. |
Signed-off-by: Mathias Pius <[email protected]>
Fix trait derivation for structs (proving the need for tests) Re-add @clux's vec/clone refactor to reduce allocation Signed-off-by: Mathias Pius <[email protected]>
Signed-off-by: Mathias Pius <[email protected]>
Signed-off-by: Mathias Pius <[email protected]>
Signed-off-by: Mathias Pius <[email protected]>
Signed-off-by: Mathias Pius <[email protected]>
I think that should be it! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very clean and separated now. Thanks a lot. I'll leave it here for a day just in case in case anyone else likes to chime in (also left an optional nit) but this is very simple to reason with now and happy to just send this out as is.
Co-authored-by: Eirik A <[email protected]> Signed-off-by: Mathias Pius <[email protected]>
Signed-off-by: Mathias Pius <[email protected]>
Signed-off-by: Mathias Pius <[email protected]>
Signed-off-by: Mathias Pius <[email protected]>
Fixes #231
This overhauls the
--derive
flag in a backwards compatible way, allowing users to specify traits to derive on a per-object basis, on all structs, all enums, or just unit-only enums.From the updated help text:
I'm still not entirely sure if the
enum:simple
syntax is the right way to go. I experimented with inverting it soenum
matched only the simple enums, and you had to doenum+complex
to trigger derivation for complex types, but that was even less intuitive since you would expectenum
to cover all enums by default.