Closed MathiasPius closed 6 months ago
Seem to have lost some code during a rebase, hang tight!
That should do it. Let me know what you think!
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 overself.derive
that decides whethers
gets derives (and even that can possibly also be parametrised inside thederive
module by passing thes
by ref in there, but that's just a stray thought).LMK what you think.
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.
I think that should be it!
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.