> enum A {
> a = 0,
> b = 1,
> c = 2
> }
>
> What I want is when I pass 2, I get c from it.
> Is there some built-in for this or some other way.
This is issue #2132 and there is no completely satisfactory answer yet.
https://github.com/mozilla/rust/issues/2132
You can use unsafe code (case::transmute), or you can do pattern matching:
match number {
0 => a,
1 => b,
2 => c,
_ => fail!()
}
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev