about summary refs log tree commit diff
path: root/library/alloc/src/slice.rs
diff options
context:
space:
mode:
authorLukas Bergdoll <lukas.bergdoll@gmail.com>2024-04-16 20:59:17 +0200
committerLukas Bergdoll <lukas.bergdoll@gmail.com>2024-05-16 17:08:56 +0200
commitd20b1190cfb92faab93e0528555753c3823d28d0 (patch)
treef564dd6f66f5fae9b0cf6898c1bd92309d2e1f96 /library/alloc/src/slice.rs
parent1a6b0e410e3b32f8641b9ee2bcf992712c8fa72f (diff)
downloadrust-d20b1190cfb92faab93e0528555753c3823d28d0.tar.gz
rust-d20b1190cfb92faab93e0528555753c3823d28d0.zip
Move BufGuard impl outside of function
Diffstat (limited to 'library/alloc/src/slice.rs')
-rw-r--r--library/alloc/src/slice.rs21
1 files changed, 10 insertions, 11 deletions
diff --git a/library/alloc/src/slice.rs b/library/alloc/src/slice.rs
index 104f4ee753b..79540fcd395 100644
--- a/library/alloc/src/slice.rs
+++ b/library/alloc/src/slice.rs
@@ -864,18 +864,17 @@ fn stable_sort<T, F>(v: &mut [T], mut is_less: F)
 where
     F: FnMut(&T, &T) -> bool,
 {
-    use sort::stable::BufGuard;
-
-    #[unstable(issue = "none", feature = "std_internals")]
-    impl<T> BufGuard<T> for Vec<T> {
-        fn with_capacity(capacity: usize) -> Self {
-            Vec::with_capacity(capacity)
-        }
+    sort::stable::sort::<T, F, Vec<T>>(v, &mut is_less);
+}
 
-        fn as_uninit_slice_mut(&mut self) -> &mut [MaybeUninit<T>] {
-            self.spare_capacity_mut()
-        }
+#[cfg(not(no_global_oom_handling))]
+#[unstable(issue = "none", feature = "std_internals")]
+impl<T> sort::stable::BufGuard<T> for Vec<T> {
+    fn with_capacity(capacity: usize) -> Self {
+        Vec::with_capacity(capacity)
     }
 
-    sort::stable::sort::<T, F, Vec<T>>(v, &mut is_less);
+    fn as_uninit_slice_mut(&mut self) -> &mut [MaybeUninit<T>] {
+        self.spare_capacity_mut()
+    }
 }