Move BufGuard impl outside of function · model-checking/verify-rust-std@736b225 (original) (raw)

Original file line number Diff line number Diff line change
@@ -864,18 +864,17 @@ fn stable_sort<T, F>(v: &mut [T], mut is_less: F)
864 864 where
865 865 F: FnMut(&T, &T) -> bool,
866 866 {
867 -use sort::stable::BufGuard;
868 -
869 -#[unstable(issue = "none", feature = "std_internals")]
870 -impl<T> BufGuard<T> for Vec<T> {
871 -fn with_capacity(capacity: usize) -> Self {
872 -Vec::with_capacity(capacity)
873 -}
867 + sort::stable::sort::<T, F, Vec<T>>(v, &mut is_less);
868 +}
874 869
875 -fn as_uninit_slice_mut(&mut self) -> &mut [MaybeUninit<T>] {
876 -self.spare_capacity_mut()
877 -}
870 +#[cfg(not(no_global_oom_handling))]
871 +#[unstable(issue = "none", feature = "std_internals")]
872 +impl<T> sort::stable::BufGuard<T> for Vec<T> {
873 +fn with_capacity(capacity: usize) -> Self {
874 +Vec::with_capacity(capacity)
878 875 }
879 876
880 - sort::stable::sort::<T, F, Vec<T>>(v, &mut is_less);
877 +fn as_uninit_slice_mut(&mut self) -> &mut [MaybeUninit<T>] {
878 +self.spare_capacity_mut()
879 +}
881 880 }