Skip to content

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

@kije

Description

@kije

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

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