Skip to content

Allow changing visibility of derived enum #6

@bgilbert

Description

@bgilbert

I'd like to have a private enum as an implementation detail of my library, but provide a public method (on another type) that returns its kind. However, it seems enum-kinds always copies the visibility of the original enum.

For example:

#[derive(EnumKind)]
#[enum_kind(FooKind)]
enum Foo {
    A(u32),
    B(u64),
}

pub fn get_a_foo() -> FooKind {
    Foo::A(0).into()
}

This produces:

error[E0446]: private type `FooKind` in public interface
  --> src/lib.rs:36:1
   |
29 | #[derive(EnumKind)]
   |          -------- `FooKind` declared as private
...
36 | pub fn get_a_foo() -> FooKind {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ can't leak private type

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions