Is `None` returned from `partial_cmp` supposed to only signify `NaN`?

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
  • to offer an implementation of some arbitrary fixed ordering for search-trees such as BTreeMap/BTreeSet
    • for this, having an Ord implementation for Result is super useful, and the arbitrary choice of how to order Ok vs Err doesn’t matter much, it just has to be decided either way and then it becomes mostly an irrelevant implementation detail anyway (ignoring BTree… operations like range or split_off where the ordering does matter)
  • 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 return bool seems somewhat limiting
4 Likes