-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
#[derive(FromPrimitive)] should use the num crate #24822
Comments
This is really an issue. At the moment there is no convenient way of converting an integer value to an enum. |
I think people can invoke a macro to define an enum, in this way they can impl From easily. |
I don’t want to write a new macro for every enum, this is as convenient as just implementing |
|
The compiler still supports
#[derive(FromPrimitive)]
but it usesstd::num::FromPrimitive
which doesn't exist anymore. The compiler should remove its built-in support for#[derive_FromPrimitive]
and thenum
crate should implement it instead.Alternatively, to avoid the need for
#![feature(custom_derive)]
, the compiler's built-in support could be adjusted to usenum::traits::FromPrimitive
instead, with the expectation that clients will adopt the externalnum
crate, but this approach is inflexible (thenum
crate can't changeFromPrimitive
without breaking compatibility).The text was updated successfully, but these errors were encountered: