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

Disabled variant still included in Count #267

Closed
schultetwin1 opened this issue Apr 24, 2023 · 0 comments · Fixed by #268
Closed

Disabled variant still included in Count #267

schultetwin1 opened this issue Apr 24, 2023 · 0 comments · Fixed by #268

Comments

@schultetwin1
Copy link
Contributor

The additional attributes docs define the disabled attribute as:

disabled: removes variant from generated code.

However, when deriving the EnumCount trait, the disabled variant is still counted in the final count.

Here is some example code:

use strum::EnumCount;

#[derive(strum::EnumCount)]
enum Fields {
    Field0,
    Field1,
    Field2,
    #[strum(disabled)]
    Unknown,
}

fn main() {
    println!("Count: {}", Fields::COUNT);
}

Expected output: Count: 3
Actual output: Count: 4

This issue seems similar to #244

schultetwin1 added a commit to schultetwin1/strum that referenced this issue Apr 26, 2023
Do not include disabled variants in the count with EnumCount. Fixes Peternator7#267
Peternator7 pushed a commit that referenced this issue Jun 18, 2023
Do not include disabled variants in the count with EnumCount. Fixes #267
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