Skip to content
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

Permit subenum to _exclude_ derives on the parent #39

Open
BatmanAoD opened this issue Oct 11, 2024 · 1 comment
Open

Permit subenum to _exclude_ derives on the parent #39

BatmanAoD opened this issue Oct 11, 2024 · 1 comment

Comments

@BatmanAoD
Copy link

subenum permits adding derives that aren't permissible on the parent, but it appears there's no way to exclude derives that aren't applicable to the child.

In particular, I want to be able to have an enum with a num_enum "catchall" enabling FromPrimitive, but a sub-enum that only contains unit variants:

#[repr(u32)]
#[subenum(OnlyUnit(derive(TryFromPrimitive)))]
#[derive(FromPrimitive)]
enum Foo {
    Bar = 1,
    Baz = 2,
    #[num_enum(catch_all)]
    Unknown(u32),
}

That is, I want OnlyUnit to contain Bar and Baz but not Unknown, making it non-exhaustive, which prevents deriving num_enum::FromPrimitive.

@BatmanAoD
Copy link
Author

This may be a duplicate of #26, but I might be misunderstanding #26.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant