What are you asking is much better to describe with a feature anonymous enums
struct MyStruct {
x: enum {V1, V2},
y: f64,
}
let ms : MyStruct = MyStruct { x: enum::V1, y : 2.0 };
let msx : enum {V1, V2} = ms.x;
As far as I knew all attempts to add this feature into the languages were not accepted.
And all attempts to add them by already existed rust-possibilities were abandoned.
Within the contexts of programming languages this is called an "unnameable type". It is given a unique type name within the context of compilation, but the code being compiled has no way of referring to it. This might still be allowed:
let ms : MyStruct = MyStruct { x: V1, y : 2.0 };
let msx = &ms.x;
but e.g. you cannot return a &MyStruct.__X__ from a function, because you can't name it. It is not an unmanageable issue as long as the variants have some way of being named (e.g. MyStruct::V1, or MyStruct::_::V1).
Overall this thread might be diverging a little by conflating the idea of declaring enums inline and making those enums anonymous. There is no reason for inline enums to be necessarily anonymous.
struct MyStruct {
x: enum X {V1, V2},
y: enum Y {V1, V2},
z: f64,
}
Please don’t be overly confrontational. This topic is becoming simultaneously a burden to moderate(1) and the discussion isn’t leading anywhere specifically, as far as I can tell.
For more focused discussion, e.g. on the pros and cons of a proposed language feature, it would make sense to actually propose a language feature, whereas this topic seems to be a broad discussion about the idea to ”declare sum types inside product types” with no syntax to construct values of those types or work with them (e.g. pattern matching).
While one should never by overly harsh in defending language proposals against criticism, it seems particularly strange to me to do so in a context where no fleshed out feature is proposed in the first place.
(1) this involves replies that are no longer visible