What would it take to revive Enum Variant Types?

I want this too, but I don't think now is the right time to revive the feature quite yet, for the following reason.

Enum variant types, where any value of an enum type that matches a specific variant is a member of a subtype corresponding to that variant, are a special case of a more general feature, where any value of a type that matches a specific pattern is a member of a subtype corresponding to that pattern. The more general feature would also encompass ranged integers, among other things.

But "types that depend on patterns" requires the details of pattern matching to be settled and specified, and there is still a lot of active work in that area (important keywords are "structural equality" and "valtrees"). I recently proposed an RFC that would have affected pattern matching, and it was closed in part because of the potential to conflict with these in-progress changes. So it's probably best to wait until the outstanding questions are resolved, before writing a detailed proposal for this feature.

7 Likes