strum icon indicating copy to clipboard operation
strum copied to clipboard

Disabled variant still included in VariantNames

Open Progdrasil opened this issue 2 years ago • 2 comments

It is my understanding that the #[strum(disabled)] attribute should remove it from all the expansions. However, it seems that it is still included in the VariantNames trait implementation.

Example code

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

Expected Output

impl ::strum::VariantNames for ResponseIdent {
        const VARIANTS: &'static [&'static str] = &[
            "Field0",
            "Field1",
            "Field2",
        ];
    }

Actual Output

impl ::strum::VariantNames for ResponseIdent {
        const VARIANTS: &'static [&'static str] = &[
            "Field0",
            "Field1",
            "Field2",
            "Unknown",
        ];
    }

Progdrasil avatar Oct 13 '22 15:10 Progdrasil

I'm facing the same issue. I'm happy to work on a fix for this and open a PR. @Peternator7

vspecky avatar Jun 29 '23 11:06 vspecky

Hi @Peternator7 👋

I was recently facing an issue related to this and took up on fixing it. I also have a PR containing a new test to check for this as well as an implemented fix to resolve this (#369 ).

Tar-Tarus avatar Jul 19 '24 10:07 Tar-Tarus