[rust-dev] RFC: Namespace enum variants under the enum

Patrick Walton pwalton at mozilla.com
Fri Mar 22 17:41:45 PDT 2013

On 3/22/13 5:10 PM, Martin DeMello wrote:
> Since this is breaking everything anyway, how about syntax to let the
> match run inside the enum namespace? e.g.
>   enum Color { Red, Green, Blue }
>      fn main() {
>          let x = Color::Red;
>          match Color::{x} {
>              Red => ...
>              Green => ...
>              Blue => ...
>          }
>      }

Seems to add complexity to the grammar for something that could be done 
with `use self::Color::*;`

> Or even infer that x is of type Color and let the compiler
> transparently allow omitting the prefix within the match.

That would intertwine name resolution and typechecking, which would add 
a lot of complexity to the compiler (if it's even coherent to do so; it 
might not be).


More information about the Rust-dev mailing list