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

EnumString match with non-default variables #295

Closed
wangxiaoying opened this issue Sep 12, 2023 · 1 comment
Closed

EnumString match with non-default variables #295

wangxiaoying opened this issue Sep 12, 2023 · 1 comment

Comments

@wangxiaoying
Copy link

wangxiaoying commented Sep 12, 2023

Is this case supported?

// definition
pub enum MyEnum {
    Variable1(bool),
    Variable2(bool),
}

// test
let v = MyEnum::from_str("Variable2(true)");

Currently it only works for MyEnum::from_str("Variable2")" and it will generate v as the default value MyEnum::Variable2(false). And for the above test, I get a VariantNotFound error.

@Peternator7
Copy link
Owner

Hi @wangxiaoying, this case isn't really supported, and I don't think there's a straightforward path to supporting it. There's the very limited case of Variable(true) that we could probably handle, but there's a huge number of formatting considerations that are all reasonable, but make this feature impractically large to support.

Sorry about that!

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

No branches or pull requests

2 participants