I've wanted enum-variant-as-a-nameable-type for a while (I have an issue comment somewhere…). I have some probing questions that should hopefully help flesh out this idea .
- How is name lookup done on the right side? Must it be
MyEnum - { MyEnum::A }
? What if it wasMyEnum - { MyEnum::None }
(where the name would be potentially ambiguous otherwise)? (This goes back to this previous thread.) - What is
Option - { Some, None }
? It should be aNever
-like type (unless the type is#[non_exhaustive]
I suppose). - Given
type MySmallerEnum = MyEnum - { MyEnum::A };
, isMySmallerEnum - { MyEnum::A }
valid? How aboutMySmallerEnum::C
(or must it still beMyEnum::C
)? - Can this stack? Given
type MyOtherSmallerEnum = MyEnum - { MyEnum::C };
, isMySmallerEnum - MyOtherSmallerEnum
possible? If so, is it the same type asMyEnum - { MyEnum::A, MyEnum::C }
or are they distinct? If distinct, do I need a.into()
for each "type subtraction" layer to get to the original? - Is
u8 - { 0 }
equivalent toNonZero<u8>
? - What is the interaction with
#[non_exhaustive]
?
Anyways, related prior work: