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

fix!: use the tuple value for to_string on default #270

Merged
merged 1 commit into from
Jun 18, 2023

Commits on May 27, 2023

  1. fix!: use the tuple value for to_string on default

    The default attribute on a tuple like variant now causes the to_string
    and display format to use the value of the tuple rather than the name
    of the variant.
    
    E.g. Color::Green("lime").to_string() will equal "lime" not "Green"
    
    Fixes: how to round trip Display and EnumString with default="true" Peternator7#86
    
    BREAKING CHANGE
    This changes how Display and ToString cause the following to renders:
    ```rust
    #[strum(default)]
    Green(String)
    ```
    To maintain the previous behavior (use the variant name):
    ```rust
    #[strum(default, to_string("Green"))]
    Green(String)
    ```
    joshka committed May 27, 2023
    Configuration menu
    Copy the full SHA
    fed5568 View commit details
    Browse the repository at this point in the history