-
-
Notifications
You must be signed in to change notification settings - Fork 886
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 eligible enums convertable to static strs #4915
Conversation
@@ -149,8 +149,7 @@ regex = "1.10.4" | |||
once_cell = "1.19.0" | |||
diesel-derive-newtype = "2.1.2" | |||
diesel-derive-enum = { version = "2.1.0", features = ["postgres"] } | |||
strum = "0.26.2" | |||
strum_macros = "0.26.4" | |||
strum = { version = "0.26.3", features = ["derive"] } |
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.
Stuff from strum_macros
can be imported from strum
when the "derive" feature is included. This makes the strum_macros
import redundant.
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.
Seems fine. I'll test this out to make sure the generated types for lemmy-js-client don't change.
Also need to run
cargo +nightly fmt
Can you show an from your leptos-ui code to see how this is helpful? |
I was originally thinking it would be useful for inserting values into query params, although it turns out both arguments for that need to be I do anticipate I'll need to use At the very least, I think removing the redundant import will be helpful, and adding another derive trait doesn't add much (if any) complexity and will be useful to anyone else who uses I can undo the derives if you feel it necessary, although I at least think we should keep the removal of the redundant dependency. |
Yes removing the extra dependencies is definitely good. But I dont like to add extra derives which arent being used. Otherwise there may be dozens or hundreds of different derives we may add, and they have a cost in terms of maintenance and compile time. |
* Make eligible enums convertable to static strs * Run cargo fmt * Remove unnecessary derives
I figure it's a good thing to avoid heap allocations where possible. Strum makes this easy for enums, allowing us to convert them to static string slices. It will also be helpful for the leptos ui since I'm using types from api common.