|
|
|
|
|
by rphln
811 days ago
|
|
Often I wish that: enum Auth { Guest, User(u32), Bot(u32) }
was just syntactic sugar for struct Auth::Guest;
struct Auth::User(u32);
struct Auth::Bot(u32);
type Auth = Auth::Guest | Auth::User | Auth::Bot;
where `|` denotes an anonymous union. Using enums feel very clunky when you start needing to work with subsets of them. |
|
The pattern type work I mentioned earlier would bring us very close to what you have at the end:
The full enum still needs to be defined. In particular, it serves as the basis the in-memory representation. All the subset can be handled by the compiler though.