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

Useful changes to EnumString #368

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AlexSherbinin
Copy link

@AlexSherbinin AlexSherbinin commented Jul 18, 2024

  1. Added support for enums that consuming strings they have parsed from.
  2. Changed behaviour to derive From trait instead of TryFrom when default variant is defined(TryFrom'll be defined automatically with Infallible as error type).

Note

Maybe a breaking change, because error type of TryFrom trait is changed from ParseError to Infallible.
Enums that consuming strings was leading to compiler error, so there's no breaking change in that part

Changes usage example:

#[derive(Debug, Eq, PartialEq, EnumString)]
#[strum(serialize_all = "UPPERCASE")]
enum HttpMethod<'a> {
    Get,
    Post,
    #[strum(default)]
    Unrecognized(&'a str),
}

… from, changed behaviour to derive `From` trait instead of `TryFrom` when default variant is defined
Copy link
Owner

@Peternator7 Peternator7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlexSherbinin, thanks for the PR! Can you revert the formatting/style changes from this PR and include only the feature updates? They're making this PR hard to review, and the git blame becomes hard to read read if it's full of formatting changes.

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

Successfully merging this pull request may close these issues.

2 participants