Skip to content

discriminants with empty enum #433

@crop2000

Description

@crop2000

I generate code that sometimes results in empty enums. I still would like to be able to derive EnumDiscriminants. The problem is that this generated function cannot be compiled:

impl<'_enum> ::core::convert::From<&'_enum UIPassiveValue> for UIPassive {
    #[inline]
    fn from(val: &'_enum UIPassiveValue) -> UIPassive {
        match val {}
    }
}

I don't really know what the most consistent behaviour would be.
I made a draft in this commit
efd6ff7
to make generate the following code:

impl<'_enum> ::core::convert::From<&'_enum UIPassiveValue> for UIPassive {
    #[inline]
    fn from(val: &'_enum UIPassiveValue) -> UIPassive {
        match val { _ => todo!(),}
    }
}

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