]> git.lizzy.rs Git - rust.git/blobdiff - library/core/src/cmp.rs
Auto merge of #102513 - RalfJung:no-more-unaligned-reference, r=cjgillot,scottmcm
[rust.git] / library / core / src / cmp.rs
index ebf5baa3c020bf898a68c25094675f4f0422e81d..b75ae996e4853b46219e4495f4ae08f1d5168fb6 100644 (file)
@@ -798,16 +798,7 @@ fn max(self, other: Self) -> Self
         Self: Sized,
         Self: ~const Destruct,
     {
-        #[cfg(not(bootstrap))]
-        {
-            max_by(self, other, Ord::cmp)
-        }
-
-        #[cfg(bootstrap)]
-        match self.cmp(&other) {
-            Ordering::Less | Ordering::Equal => other,
-            Ordering::Greater => self,
-        }
+        max_by(self, other, Ord::cmp)
     }
 
     /// Compares and returns the minimum of two values.
@@ -828,16 +819,7 @@ fn min(self, other: Self) -> Self
         Self: Sized,
         Self: ~const Destruct,
     {
-        #[cfg(not(bootstrap))]
-        {
-            min_by(self, other, Ord::cmp)
-        }
-
-        #[cfg(bootstrap)]
-        match self.cmp(&other) {
-            Ordering::Less | Ordering::Equal => self,
-            Ordering::Greater => other,
-        }
+        min_by(self, other, Ord::cmp)
     }
 
     /// Restrict a value to a certain interval.
@@ -1234,17 +1216,7 @@ pub const fn min_by_key<T, F: ~const FnMut(&T) -> K, K: ~const Ord>(v1: T, v2: T
     F: ~const Destruct,
     K: ~const Destruct,
 {
-    const fn imp<T, F: ~const FnMut(&T) -> K, K: ~const Ord>(
-        f: &mut F,
-        (v1, v2): (&T, &T),
-    ) -> Ordering
-    where
-        T: ~const Destruct,
-        K: ~const Destruct,
-    {
-        f(v1).cmp(&f(v2))
-    }
-    min_by(v1, v2, ConstFnMutClosure::new(&mut f, imp))
+    min_by(v1, v2, const |v1, v2| f(v1).cmp(&f(v2)))
 }
 
 /// Compares and returns the maximum of two values.