Add `chmax` / `chmin` functions to standard library

Hi

I suggest new methods for Ord working like below:

trait Ord {
  fn chmax(&mut self, other: Self) -> bool { ... }
  fn chmin(&mut self, other: Self) -> bool { ... }
}
x.chmax(y);
// x = x.max(y);

x.chmin(y);
// x = x.min(y);

The method chmax replaces self and returns true if self < other, else returns false
The method chmin works in same way

Also I suggest adding these methods for Option<T> where T: Ord

impl<T> Option<T> {
  fn chmin(&mut self, other: T) where T: Ord { ... }
  fn chmin(&mut self, other: T) where T: Ord { ... }
}

Suggesting changes to the language or the stdlib is off-topic here, it should be discussed on IRLO.

1 Like

Thank you!

I'll close this topic here