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

FromPrimitive with values not covered by existing enum #31

Open
soumya92 opened this issue Aug 30, 2019 · 0 comments
Open

FromPrimitive with values not covered by existing enum #31

soumya92 opened this issue Aug 30, 2019 · 0 comments

Comments

@soumya92
Copy link

soumya92 commented Aug 30, 2019

If I have

enum Foo {
  FooA = 3,
  FooB = 7,
  OtherFoo(u8),
}

it would be nice to have some way to specify that:

Foo::from_u8(3) == Some(FooA),
Foo::from_u16(7) == Some(FooB),
Foo::from_u8(4) == Some(FooOther(4)),
Foo::from_i32(5) == Some(FooOther(5)),
Foo::from_i32(1024) == None,
...
@soumya92 soumya92 changed the title FromPrimitive with values outside enum range FromPrimitive with values not covered by existing enum Aug 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants