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

How can I set the visibility of the generated accessors from EnumAccess? #3

Open
kije opened this issue Sep 10, 2023 · 0 comments
Open

Comments

@kije
Copy link

kije commented Sep 10, 2023

Currently it seems the generated accessors are private. Is there a way to generate them with a different visibility, e.g. pub or pub(crate).

I need this because I define my enum in one Module, but need the accessors in another module.

Sample code:

mod mod_a {
   #[derive(Hash, Eq, PartialEq, Debug, Clone, Copy, EnumAccess)]
   #[enum_access(get(name))] 
   pub enum Factor { 
       SingleValue{ name: String },
       MultipleValue{ name: String  }
   }
}

mod mod_b {
    use super::mod_a::Factor;
    fn my_fn() {
       let factor = Factor::SingleValue{ name: "Foo".to_string() };

       factor.name(); // error[E0624]: method `name` is private
    }
}
@kije kije changed the title How can I set the visibility of the generated ccessors from EnumAccess? How can I set the visibility of the generated accessors from EnumAccess? Sep 10, 2023
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