Skip to content

Comparison semantics may be unexpected #53

@ronnodas

Description

@ronnodas

As implemented, comparison between BitFlags is not the same as contains and depends on the bit assigned to each variant (explicitly or implicitly via the ordering of the variants). This is needed to implement Ord but may not be the expected semantics of a <= b. It would be nice if this was explained in the documentation.

One could even argue that BitFlags<Enum> should not implement Ord but only PartialOrd (with the semantics a <= b iff b.contains(a)) except maybe if Enum implements Ord.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions