mozilla/rust — pull request #13860 by kemurphy (2014-04-30 10:52:20+00:00)
Title: Add num_variants intrinsic for enums and safe wrapper in std::reflect.

This adds an intrinsic to query the number of variants in an enum, along with a safe wrapper for it in std::reflect:

```rust
use std::reflect::num_variants;

enum Shape {
Triangle,
Square,
Circle,
}

static num_shapes: uint = num_variants::(); // returns 3
```

If the type parameter is not an enum, the result is 0.