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

Allow for additional variants in destination #1

Open
RXminuS opened this issue Jan 12, 2022 · 1 comment
Open

Allow for additional variants in destination #1

RXminuS opened this issue Jan 12, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@RXminuS
Copy link

RXminuS commented Jan 12, 2022

Woudl be great if there was a way of annotating that a case in the destination variant doesn't exist in the source variant. Right now I'd get a no variant or associated item named "XXX" found for enum since it tries to convert to an equally named variant from the source if I leave it un-annotated/empty.

@abrgr
Copy link
Member

abrgr commented Mar 14, 2022

What do you think about adding an annotation to unused cases to preserve the default behavior of mapping by name? Maybe we use the existing from_case syntax but setting the source case to _ has the effect of shipping it? For example:

#[derive(FromEnum, Debug, PartialEq, Eq)]
#[from_enum(Src)]
enum Dest {
    Case1(),

    Case2(),

    #[from_case(_)]
    DestCase3 { a: DestStrField, b: u8 },
}

@abrgr abrgr self-assigned this Mar 14, 2022
@abrgr abrgr added the enhancement New feature or request label Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants