graydon/rust — Issue #1393: support explicit discriminant numbers on tag variants
Author: graydon
Created: 2011-12-29 22:26:32+00:00
State: open

Currently tags always use 0 ... N, where N is the number of tag variants, as the discriminant values.

This makes them useless for modeling C enums, which they are the natural analogue of. We should support a form of variant-declarator that provides a discriminant value, as (say) an uint const expression or something.

Ideal sort of example:

tag color {
red = 0xff;
blue = 0xfe;
}

It'd also be nice to be able to cast back and forth against uint values, and similar "like in C" enum tricks. But one thing at a time.