-
Notifications
You must be signed in to change notification settings - Fork 126
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
From for unit enum variants #408
Comments
Yeah, this these derives for What did you use it for? |
Regarding the easiest to maintain solution: Depending on how many times you need this, it be just be the easiest to implement the |
Manual implementation is not hard, but in my case, I wanted to achieve something like #[derive(Display)]
#[display("{_variant}")]
enum Inner {
Y,
K,
N,
E,
} I'm not sure if allowing |
I looked at where I was using it and really the only advantage is that it's usually shorter to type |
@sjunepark You can use @spearman thank you, then I'll close this issue. |
It seems like in the change from version 0.99 to version 1.0 that unit enum variants no longer implement from unit () by default.
For example:
Only implements
From<bool>
,From<i32>
andFrom<String>
, whereas before it would also implementFrom<()>
. I tried adding the#[from]
attribute to the unit variant, but then it doesn't implement From for any of the other variants, so they also need to#[from]
attribute so I end up with:Is there a better way to do this?
The text was updated successfully, but these errors were encountered: