Stream: general

Topic: Add relational operators to std


gnzlbg (Nov 27 2019 at 19:16, on Zulip):

Can we add relational operators to libcore, e.g.,

// in core::ops
trait LessThan {
  type Target;
  fn less_than(self, RHS) -> Self::Target;
}
impl<T: PartialOrd> LessThan<T> for T { /* dispatch to partial ord */ }

?

Or are any design issues that make this impossible?

XAMPPRocky (Nov 27 2019 at 19:59, on Zulip):

@gnzlbg I don't know about libcore specifically but these are available in typenum. https://docs.rs/typenum/1.11.2/typenum/type_operators/index.html

rkruppe (Nov 27 2019 at 20:01, on Zulip):

For clarification: do you want the <, >=, etc. operators to desugar to those new traits instead of PartialOrd? If not, I don't really see the point of adding them.

gnzlbg (Nov 27 2019 at 20:06, on Zulip):

Do you want the <, >=, etc. operators to desugar to those new traits instead of PartialOrd?

Yes.

Last update: Dec 12 2019 at 01:35UTC