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

Fixed the fmt conflict caused by using use std::fmt::Debug #322

Merged
merged 1 commit into from Jan 7, 2024

Conversation

disoul
Copy link
Contributor

@disoul disoul commented Jan 2, 2024

use std::fmt::Debug; // <--- add this line, for example some people might wish to custom implement the Debug trait

#[derive(Eq, PartialEq, EnumString, Display, EnumCount, EnumDiscriminants, EnumIs)]
pub enum Color {
    /// Docs on red
    #[strum(to_string = "RedRed")]
    Red,
    #[strum(serialize = "b", to_string = "blue")]
    Blue { hue: usize },
    #[strum(serialize = "y", serialize = "yellow")]
    Yellow,
    #[strum(disabled)]
    Green(String),
}

impl Debug for Color {
    ...
}

This will cause the following error.

error[E0034]: multiple applicable items in scope
 --> strum_tests/src/lib.rs:5:44
  |
5 | #[derive(Debug, Eq, PartialEq, EnumString, Display, EnumCount, EnumDiscriminants, EnumIs)]
  |                                            ^^^^^^^ multiple `fmt` found
  |
  = note: candidate #1 is defined in an impl of the trait `Debug` for the type `str`
  = note: candidate #2 is defined in an impl of the trait `std::fmt::Display` for the type `str`
  = note: this error originates in the derive macro `Display` (in Nightly builds, run with -Z macro-backtrace for more info)

@Peternator7
Copy link
Owner

Good catch; thanks for the fix

@Peternator7 Peternator7 merged commit e34e66c into Peternator7:master Jan 7, 2024
1 check passed
mich181189 pushed a commit to mich181189/strum that referenced this pull request Jan 17, 2024
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.

None yet

2 participants