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

When implementing EnumString on nested enum it requires Default implementation for nested enums #388

Open
bWanShiTong opened this issue Oct 22, 2024 · 0 comments

Comments

@bWanShiTong
Copy link

Code required to reproduce:

use strum::EnumString;

#[derive(Debug, Clone, Copy, EnumString)]
enum Nested {
    EnumA(EnumA),
    EnumB(EnumB),
}

#[derive(Debug, Clone, Copy, EnumString)]
enum EnumA {
    Variant1,
    Variant2,
}

#[derive(Debug, Clone, Copy, EnumString)]
enum EnumB {
    Variant3,
    Variant4,
}

fn main() {}

Error:

error[E0277]: the trait bound `EnumA: Default` is not satisfied
 --> src/main.rs:3:30
  |
3 | #[derive(Debug, Clone, Copy, EnumString)]
  |                              ^^^^^^^^^^ the trait `Default` is not implemented for `EnumA`
  |
  = note: this error originates in the derive macro `EnumString` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0277]: the trait bound `EnumB: Default` is not satisfied
 --> src/main.rs:3:30
  |
3 | #[derive(Debug, Clone, Copy, EnumString)]
  |                              ^^^^^^^^^^ the trait `Default` is not implemented for `EnumB`
  |
  = note: this error originates in the derive macro `EnumString` (in Nightly builds, run with -Z macro-backtrace for more info)

For more information about this error, try `rustc --explain E0277`.
error: could not compile `testing` (bin "testing") due to 2 previous errors
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

1 participant