-
Notifications
You must be signed in to change notification settings - Fork 34
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
How aboyt impl Default when use #[num_enum(default)]
?
#56
Comments
I can see that this would be useful, but I'm slightly concerned that automatically deriving a standard trait may lead to conflicting implementations. Deriving #![feature(derive_default_enum)]
#[derive(Default)]
enum Number {
Zero,
#[default]
One,
} It would be a shame if this code: #![feature(derive_default_enum)]
#[derive(Default, num_enum::FromPrimitive)]
enum Number {
Zero,
#[default]
#[num_enum(default)]
One,
} generated two conflicting implementations of What do you think about waiting for Alternatively, we could add an explicit I definitely think that we should make the |
@illicitonion I believe that we could emit the |
I agree that we could give a clear error message - my concern is more around what the user can do to resolve the error. Generally I think people should prefer using I could get more on-board with a #[derive(num_enum::Default, num_enum::FromPrimitive)]
enum Number {
Zero,
#[num_enum(default)]
One,
} so that if someone wrote: #[derive(Default)]
#[derive(num_enum::Default, num_enum::FromPrimitive)]
enum Number {
Zero,
#[num_enum(default)]
One,
} they could choose to remove the |
Agreed, I somehow thought |
I just released 0.5.4 which includes a |
How aboyt auto impl Default when use
#[num_enum(default)]
ofFromPrimitive
?The text was updated successfully, but these errors were encountered: