diff options
| author | Nick Whitney <ubersentinel@gmail.com> | 2017-06-06 23:00:09 -0400 |
|---|---|---|
| committer | Nick Whitney <ubersentinel@gmail.com> | 2017-06-06 23:00:09 -0400 |
| commit | a32ffc679702e3ae307c7fc20873c9e970a8894c (patch) | |
| tree | e8c0fc5c03eefb45e3b9d0a4e252b853cb16cdb1 | |
| parent | 2cadc32b66e135eeb9ac22d433cd931b021792a5 (diff) | |
| download | rust-a32ffc679702e3ae307c7fc20873c9e970a8894c.tar.gz rust-a32ffc679702e3ae307c7fc20873c9e970a8894c.zip | |
Alias std::cmp::max/min to Ord::max/min
| -rw-r--r-- | src/libcore/cmp.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 4c50b11e705..6f35d0417f1 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -714,6 +714,8 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> { /// /// Returns the first argument if the comparison determines them to be equal. /// +/// Internally uses an alias to `Ord::min`. +/// /// # Examples /// /// ``` @@ -725,13 +727,15 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn min<T: Ord>(v1: T, v2: T) -> T { - if v1 <= v2 { v1 } else { v2 } + v1.min(v2) } /// Compares and returns the maximum of two values. /// /// Returns the second argument if the comparison determines them to be equal. /// +/// Internally uses an alias to `Ord::max`. +/// /// # Examples /// /// ``` @@ -743,7 +747,7 @@ pub fn min<T: Ord>(v1: T, v2: T) -> T { #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn max<T: Ord>(v1: T, v2: T) -> T { - if v2 >= v1 { v2 } else { v1 } + v1.max(v2) } // Implementation of PartialEq, Eq, PartialOrd and Ord for primitive types |
