I would like to have the following two enums. However, the below code fails to compile due to the "duplicate definition" of LargestMagnitude
and SmallestMagnitude
.
enum SymmetricWhich {
LargestMagnitude,
SmallestMagnitude,
LargestAlgebraic,
SmallestAlgebraic,
BothEnds,
}
enum NonsymmetricWhich {
LargestMagnitude,
SmallestMagnitude,
LargestRealPart,
SmallestRealPart,
LargestImaginaryPart,
SmallestImaginaryPart,
}
How can I avoid this duplicate definition? Is there any way without needing to rename enum values within one of them? I considered the possibility of moving the duplicated values to a third enum (given below as CommonWhich
), hoping I could then "derive" from is as a base class, but it is not clear to me if (or how) Rust supports this.
enum CommonWhich {
LargestMagnitude,
SmallestMagnitude,
}
What is the best way to proceed?