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

Proposal: Exclude macro for EnumIter macro #290

Open
1uf3 opened this issue Aug 5, 2023 · 0 comments
Open

Proposal: Exclude macro for EnumIter macro #290

1uf3 opened this issue Aug 5, 2023 · 0 comments

Comments

@1uf3
Copy link

1uf3 commented Aug 5, 2023

I would like a macro that does not put only certain elements in the EnumIter that creates an iterator for all Enum elements.

Example.

use strum::IntoEnumIterator;
use strum_macros::EnumIter;

#[derive(EnumIter, Debug, PartialEq)]
enum Color {
    Red,
    Green { range: usize },
    Blue(usize),
    #[exclude]
    Yellow,
}


let mut ci = Color::iter();
assert_eq!(Some(Color::Red), ci.next());
assert_eq!(Some(Color::Green {range: 0}), ci.next());
assert_eq!(Some(Color::Blue(0)), ci.next());
assert_eq!(None, ci.next());
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