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

#[derive(FromPrimitive)] should use the num crate #24822

Closed
lilyball opened this issue Apr 25, 2015 · 4 comments
Closed

#[derive(FromPrimitive)] should use the num crate #24822

lilyball opened this issue Apr 25, 2015 · 4 comments

Comments

@lilyball
Copy link
Contributor

The compiler still supports #[derive(FromPrimitive)] but it uses std::num::FromPrimitive which doesn't exist anymore. The compiler should remove its built-in support for #[derive_FromPrimitive] and the num crate should implement it instead.

Alternatively, to avoid the need for #![feature(custom_derive)], the compiler's built-in support could be adjusted to use num::traits::FromPrimitive instead, with the expectation that clients will adopt the external num crate, but this approach is inflexible (the num crate can't change FromPrimitive without breaking compatibility).

@nwin
Copy link
Contributor

nwin commented May 1, 2015

This is really an issue. At the moment there is no convenient way of converting an integer value to an enum. enum_primitive also doesn’t work because of #24189.

@bombless
Copy link
Contributor

bombless commented May 1, 2015

I think people can invoke a macro to define an enum, in this way they can impl From easily.
edit: typo

@nwin
Copy link
Contributor

nwin commented May 1, 2015

I don’t want to write a new macro for every enum, this is as convenient as just implementing From manually.

@durka
Copy link
Contributor

durka commented Mar 3, 2016

#[derive(FromPrimitive)] was removed in #31400 so this can be closed.

@sfackler sfackler closed this as completed Mar 3, 2016
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

6 participants