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 { ... }
}