Compose two `Ordering`s using transitive relations

Wouldn't it be convenient to have the following API that "composes" two Ordering according to the transitive relations? I'm not sure with the naming though.

impl Ordering {
  fn compose(self, other: Ordering) -> Option<Ordering> {
    use Ordering::*;
    match (a, b) {
        (x, Equal) | (Equal, x) => Some(x),
        (Less, Less) | (Greater, Greater) => Some(a),
        _ => None,

Great minds think alike!

EDIT: but my mind is clearly not great, since it misinterpreted what you meant by “compose”

Do you mean match(self, other)?

Anyway, what’s the use case for this operation?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.