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

Allow changing visibility of derived enum #6

Open
bgilbert opened this issue Jul 15, 2022 · 0 comments
Open

Allow changing visibility of derived enum #6

bgilbert opened this issue Jul 15, 2022 · 0 comments

Comments

@bgilbert
Copy link

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
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