Skip to content

Should stable crates derive PartialOrd/Ord on enums? #3865

@tcharding

Description

@tcharding

Currently units::amount::Denomination does not implement PartialOrd or Ord. This prevents any type that includes a Denomination from being used in contexts that require these traits (e.g. as key to a BTreeMap). This is an unnecessary restriction. We should either implement the traits or implement ArbitraryOrd.

This raises the question - "should stable crates derive PartialOrd and Ord on enums"? Doing so locks us in to not being able to re-order the variants (which would otherwise be an internal refactor) because the derived impls use the enum integer value (0 for the first variant, 1 for the second etc).

Since we have ArbitraryOrd should we be using it for all enums? Or perhaps should we be manually implementing PartialOrd and Ord?

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