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

EnumIter does not work for enums named 'Option' #299

Closed
horacimacias opened this issue Sep 28, 2023 · 0 comments · Fixed by #300
Closed

EnumIter does not work for enums named 'Option' #299

horacimacias opened this issue Sep 28, 2023 · 0 comments · Fixed by #300

Comments

@horacimacias
Copy link
Contributor

I'm using some code that has generated structs and enums, and some of the enumerations are called Option. They are on their own module/crate but there seems to be a conflict with the std::option::Option.

The following does work (note Options, not Option as the name of the enum)

#[derive(strum_macros::EnumIter, Debug)]
pub enum Options {
    Open,
    Closed,
}

use strum::IntoEnumIterator;
fn main() {
    for variant in crate::Options::iter() {
        println!("The door is {:?}", variant);
    }
}

the following does not work (the name of the enum is now Option)

#[derive(strum_macros::EnumIter, Debug)]
pub enum Option {
    Open,
    Closed,
}

use strum::IntoEnumIterator;
fn main() {
    for variant in crate::Option::iter() {
        println!("The door is {:?}", variant);
    }
}
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

Successfully merging a pull request may close this issue.

1 participant