Skip to content

Permit subenum to _exclude_ derives on the parent #39

Closed

Description

@BatmanAoD

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.

Activity

  1. BatmanAoD commented on Oct 11, 2024

    @BatmanAoD
    Author

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

  2. paholg commented on Apr 26, 2026

    @paholg
    Owner

    I believe this is solved by #54. Please re-open if I'm wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions