Enums don't support multiple variants with the same definition.
Hi, I'm new to Rust so can't really debug the code but I encountered the following issue:
If you have an Enum that has 2 different variants that share the same struct then the build fails.
use enum_dispatch::enum_dispatch;
struct A {}
impl SomeTrait for A {
fn name(&self) -> String {
"Struct A".to_string()
}
}
#[enum_dispatch(SomeTrait)]
enum Enum {
A(A),
AltA(A),
}
#[enum_dispatch]
trait SomeTrait {
fn name(&self) -> String;
}
fn main() {}
this will fail with:
error[E0119]: conflicting implementations of trait `From<A>` for type `Enum`
--> src\main.rs:18:1
|
18 | #[enum_dispatch]
| ^^^^^^^^^^^^^^^^
| |
| first implementation here
| conflicting implementation for `Enum`
|
= note: this error originates in the attribute macro `enum_dispatch` (in Nightly builds, run with -Z macro-backtrace for more info)
Is this something that can be trivially fixed or it just can't be done? :D