We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d02cab1 commit de08218Copy full SHA for de08218
library/core/src/cmp.rs
@@ -800,7 +800,10 @@ pub trait Ord: Eq + PartialOrd<Self> {
800
Self: Sized,
801
Self: ~const Destruct,
802
{
803
- max_by(self, other, Ord::cmp)
+ match self.cmp(&other) {
804
+ Ordering::Less | Ordering::Equal => other,
805
+ Ordering::Greater => self,
806
+ }
807
}
808
809
/// Compares and returns the minimum of two values.
@@ -821,7 +824,10 @@ pub trait Ord: Eq + PartialOrd<Self> {
821
824
822
825
823
826
- min_by(self, other, Ord::cmp)
827
828
+ Ordering::Less | Ordering::Equal => self,
829
+ Ordering::Greater => other,
830
831
832
833
/// Restrict a value to a certain interval.
0 commit comments