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

EnumString should derive From<&str> instead of TryFrom<&str> when #[strum(default)] is present #307

Open
MingweiSamuel opened this issue Oct 13, 2023 · 1 comment

Comments

@MingweiSamuel
Copy link

MingweiSamuel commented Oct 13, 2023

If you derive EnumString on a enum with a #[strum(default)] it generates a TryFrom<&str> implementation which can never return an error. It would make sense to generate From<&str> instead

This would be a breaking change

@k9withabone
Copy link

I think strum should still generate a FromStr and TryFrom<&str> implementation, but with the error type as Infallible, in addition to generating a From<&str> (and maybe From<String>).

This would allow me to use strum in a library I'm writing without having strum types as part of the API.

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

2 participants