EnumIs: Allow custom variant function names#336
EnumIs: Allow custom variant function names#336Mange wants to merge 2 commits intoPeternator7:masterfrom
Conversation
|
Is there anything else I can do here to help out? :-) |
|
Hi @Mange, sorry for the delay here. It's been a busy few weeks. PR looks generally good, and makes sense to me. Two quick things:
|
|
Serde had a similar thing with Perhaps we could do something similar to this here, either: #[strum(name = "other_name")] // uses the name for all derives.
#[strum(name = (enum_is = "other_name")] // uses default name for other derives.
// …or, to make configuration appear more scoped, only allow `name` to be for an
// explicit derive kind.
#[strum(enum_is = (name = "other_name"))] |
|
Sorry for the delay getting back to you. I've been thinking a good bit about this. It's a big change, but I think adopting the same convention as serde is reasonable, and I'd be willing to start the migration. If we do, let's just use the same language that serde uses (aka This is going to be a bigger change, but will likely be good for the long term consistency of strum and probably any apps that use both strum and serde |
I have an enum that basically looks like this:
When deriving
EnumIsfor this enum I getis_u_8, which I want to replace withis_u8instead. This PR implements the following workaround:This could still be useful for other cases, perhaps one want to rename
Booleantois_bool, for example.I've also fixed warnings that were emitted while running tests, and some Clippy warnings in the
enum_istests file.