Skip to content

Support variants with Option fields #2

@juancampa

Description

@juancampa

Some variants can have a common field wrapped in an Option.

So, for example:

enum MyEnum {
  A { name: String },
  B,
  C { name: Option<String> },
}

I expect .name() to work and return an Option<String>. However, we get an error because not all variants have the same type for the name field.

Instead, it would be nice to detect this case and append a .flatten() to the accessor.

Super useful crate. I'm surprised it isn't more popular

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions