Closed targrub closed 7 months ago
Could you expand on the use case it might solve? Also, what would the comparison do? Compare the vector lengths ?
Ord is a surprisingly useful trait on weird types, as it allows for them to be stored in data structures like BTreeSet.
Ord is a surprisingly useful trait on weird types, as it allows for them to be stored in data structures like BTreeSet.
Agreed but there are multiple valid comparisons:
x
then y
y
then x
length
And choosing one seems like the wrong way to go, there could be wrappers like OrdByXY(Hex)
, OrdByYX(Hex)
and OrdByLength(Hex)
implementing both PartialOrd
and Ord
My use case was just to be able to test whether two Vec<Hex>
s were equal or not.
No need of Ord for that, unless you need sorting. But then I would advise sorting manually by one the three options. If you share a code snippet I can help you with that
Was user error. Withdrawing PR. But I do have confusion about this guideline: https://rust-lang.github.io/api-guidelines/interoperability.html#c-common-traits
Motivation: To allow use of std::cmp with Vec. https://rust-lang.github.io/api-guidelines/interoperability.html#c-common-traits