Move BufGuard impl outside of function

This commit is contained in:
Lukas Bergdoll 2024-04-16 20:59:17 +02:00
parent 1a6b0e410e
commit d20b1190cf

View File

@ -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)
}
fn as_uninit_slice_mut(&mut self) -> &mut [MaybeUninit<T>] {
self.spare_capacity_mut()
}
}
sort::stable::sort::<T, F, Vec<T>>(v, &mut is_less);
}
#[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)
}
fn as_uninit_slice_mut(&mut self) -> &mut [MaybeUninit<T>] {
self.spare_capacity_mut()
}
}