Skip to content

Document how to implement CLike for using EnumSet #13752

Closed
@SimonSapin

Description

@SimonSapin

According to the tests, this code needed to use collections::enum_set::EnumSet:

    #[repr(uint)]
    enum Foo {
        A, B, C
    }

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

        fn from_uint(v: uint) -> Foo {
            unsafe { cast::transmute(v) }
        }
    }

If it is indeed needed, that should be documented.

Also, it would be nice to not have to duplicate this impl for every enum type that one wants to use with EnumSet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions