You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I come across your project and it's great, I find the feature to sort derives really usefull. I think it could be improved by grouping derives by their crate and then order them, it could be great. What do you think ? Would you be interested in a PR with this feature ?
The text was updated successfully, but these errors were encountered:
Grouping by crates might be difficult to achieve because often crates are not stated explicitly. Figuring out the right crate in this case increases the complexity significantly. Here's a table of derive traits by their frequency in a big repo, you can see similar traits are used with and without crate names.
Adding another very specific type of sorting to already provided Canonical and Alphabetical might bring more harm than good -- more possibility everyone to go different directions. My preference is that rustfmt implements a single one and only right order and make everyone stick to it. Unfortunately it's not the case yet, so I implemented it in my tool as a workaround. Maybe even 2 is too many :)
... but! there might be an option for a universal 3rd one -- Custom when user provides their own priority list. Then everyone can go wild.
As a bottom line:
no, I wouldn't want to implement 'group by crate' option, since it's too specific
maybe I would be interested to add Custom option which allows everyone to use their own order, but I am hesitant because of 'pandora box' issue
and lastly I don't have capacity at the moment to work on this, so it's rather no
As a workaround you may want to look at cargo-sort-derives crate which has Custom option. But it has its own issues (like sorting everything by regex including comments and string lines).
maksym-arutyunyan
changed the title
Canincal order could group derives by crate
Canonincal order could group derives by crate
Oct 7, 2024
Hi,
I come across your project and it's great, I find the feature to sort derives really usefull. I think it could be improved by grouping derives by their crate and then order them, it could be great. What do you think ? Would you be interested in a PR with this feature ?
The text was updated successfully, but these errors were encountered: