Skip to content

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
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.

2 participants