enumset icon indicating copy to clipboard operation
enumset copied to clipboard

`#[derive(EnumSetType)]` can only be used on fieldless enums

Open KaranJain21 opened this issue 7 months ago • 4 comments

Can we make EnumSet work on enums with fields where the fields impl EnumSetType?

E.g.

#[derive(EnumSetType)]
enum MyEnum {
    A
    B(MyEnumInner)
}

#[derive(EnumSetType)]
enum MyEnumInner {
    C
    D
}

Currently this works on MyEnumInner but not on MyEnum.

KaranJain21 avatar May 16 '25 22:05 KaranJain21

This is unfortunately very hard to implement, and unlikely to change soon. However, it is possible to do and I do plan to do it eventually.

Lymia avatar May 18 '25 05:05 Lymia

@KaranJain21

For a workaround, consider using https://crates.io/crates/enum-kinds.

Update 1:

apparently, it's not a solution because there are conflicting implementations.

Update 2:

I opened an issue there https://github.com/Soft/enum-kinds/issues/11.

Update 3:

Apparently, there's also kinded crate, which is probably better than enum-kinds but also has the problem with conflicting implementations.

Update 4:

I've made a PR to kinded that adds an option to opt-out of default derives. So now my fork of kinded and the original enumset are compatible. Based on my observations, kinded is not actively maintained. However, the author of the crate is in my friend list of LinkedIn so I should be able to get in contact with him.

JohnScience avatar Oct 25 '25 20:10 JohnScience

@Lymia Consider referencing the kinded crate in the Limitations section of the documentation and consider adding an option to opt-out of default derives so that your crate is more compatible with others.

JohnScience avatar Oct 25 '25 20:10 JohnScience

@JohnScience This feature should already with the #[enumset(no_super_impls)] and #[enumset(no_ops)] options.

Lymia avatar Nov 02 '25 23:11 Lymia