The problem is that Ord
(together with PartialOrd
) serves multiple purposes
- to provide a semantic notion of ordering that makes sense for the given type
- under this aspect, ordering
Ok
vs.Err
doesn’t make too much sense
- under this aspect, ordering
- to offer an implementation of some arbitrary fixed ordering for search-trees such as
BTreeMap
/BTreeSet
- for this, having an
Ord
implementation forResult
is super useful, and the arbitrary choice of how to orderOk
vsErr
doesn’t matter much, it just has to be decided either way and then it becomes mostly an irrelevant implementation detail anyway (ignoringBTree…
operations likerange
orsplit_off
where the ordering does matter)
- for this, having an
- to offer an overloading of
<
/<=
/>
/>=
operators- for this, it’s kind-of redundant/overkill/limiting to have any constraints on their implementations listed at all on the respective traits; after all, operators like
+
allow any arbitrary operation, too, and don’t document any laws those should uphold, such as(a + b) + c) == a + (b + c)
and the like; even the fact that they always need to returnbool
seems somewhat limiting
- for this, it’s kind-of redundant/overkill/limiting to have any constraints on their implementations listed at all on the respective traits; after all, operators like