Skip to content

Sets should not impl Ord, and should impl PartialOrd differently (?) #16570

Closed
@Gankra

Description

@Gankra

Currently, sets that have some notion of an ordering over their elements (TreeSet and BitvSet, at least) implement Ord in terms of the lexicographic ordering of their contents. However, as @apoelstra notes in #16559 it may be more natural for sets to be ordered by inclusion. That is, a<=b if a subseteq b.

However, there is no total ordering over set inclusion. It instead forms a diamond-shaped DAG. Thus, Sets would not implement Ord under this scheme. In fact, almost all pairs of sets would have cmp yield None, which makes it a not-very-useful operator for generic comparison. Further, inclusion relationships are already provided by the actual Set api.

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