Is it possible to somehow automatically derive
collections::enum_set::CLike for a enum? The idea of writing

impl CLike for MyEnum {
    fn to_uint(&self) -> uint {
        return *self as uint;
    }

    fn from_uint(n: uint) -> Flag {
        match n {
            0 => EnumConst1,
            ...
            _ => fail!("{} does not match any enum case, n)
        }
    }
}

just to get a type safe bit set EnumSet<MyEnum> is rather discouraging.

On a related note I see that EnumSet never checks that CLike::to_int
result stays below the word size. Is it a bug?
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to