|
9 | 9 | //! In addition it also contains the core logic of the stable sort used by `slice::sort` based on
|
10 | 10 | //! TimSort.
|
11 | 11 |
|
12 |
| -#![allow(unused)] // FIXME debug |
13 |
| - |
14 | 12 | use crate::cmp;
|
15 | 13 | use crate::mem::{self, MaybeUninit, SizedTypeProperties};
|
16 | 14 | use crate::ptr;
|
@@ -1167,7 +1165,7 @@ pub fn merge_sort<T, CmpF, ElemAllocF, ElemDeallocF, RunAllocF, RunDeallocF>(
|
1167 | 1165 | // shallow copies of the contents of `v` without risking the dtors running on copies if
|
1168 | 1166 | // `is_less` panics. When merging two sorted runs, this buffer holds a copy of the shorter run,
|
1169 | 1167 | // which will always have length at most `len / 2`.
|
1170 |
| - let mut buf = BufGuard::new(len / 2, elem_alloc_fn, elem_dealloc_fn); |
| 1168 | + let buf = BufGuard::new(len / 2, elem_alloc_fn, elem_dealloc_fn); |
1171 | 1169 | let buf_ptr = buf.buf_ptr;
|
1172 | 1170 |
|
1173 | 1171 | let mut runs = RunVec::new(run_alloc_fn, run_dealloc_fn);
|
@@ -1255,30 +1253,33 @@ pub fn merge_sort<T, CmpF, ElemAllocF, ElemDeallocF, RunAllocF, RunDeallocF>(
|
1255 | 1253 | // Extremely basic versions of Vec.
|
1256 | 1254 | // Their use is super limited and by having the code here, it allows reuse between the sort
|
1257 | 1255 | // implementations.
|
1258 |
| - struct BufGuard<T, ElemAllocF, ElemDeallocF> |
| 1256 | + struct BufGuard<T, ElemDeallocF> |
1259 | 1257 | where
|
1260 |
| - ElemAllocF: Fn(usize) -> *mut T, |
1261 | 1258 | ElemDeallocF: Fn(*mut T, usize),
|
1262 | 1259 | {
|
1263 | 1260 | buf_ptr: *mut T,
|
1264 | 1261 | capacity: usize,
|
1265 |
| - elem_alloc_fn: ElemAllocF, |
1266 | 1262 | elem_dealloc_fn: ElemDeallocF,
|
1267 | 1263 | }
|
1268 | 1264 |
|
1269 |
| - impl<T, ElemAllocF, ElemDeallocF> BufGuard<T, ElemAllocF, ElemDeallocF> |
| 1265 | + impl<T, ElemDeallocF> BufGuard<T, ElemDeallocF> |
1270 | 1266 | where
|
1271 |
| - ElemAllocF: Fn(usize) -> *mut T, |
1272 | 1267 | ElemDeallocF: Fn(*mut T, usize),
|
1273 | 1268 | {
|
1274 |
| - fn new(len: usize, elem_alloc_fn: ElemAllocF, elem_dealloc_fn: ElemDeallocF) -> Self { |
1275 |
| - Self { buf_ptr: elem_alloc_fn(len), capacity: len, elem_alloc_fn, elem_dealloc_fn } |
| 1269 | + fn new<ElemAllocF>( |
| 1270 | + len: usize, |
| 1271 | + elem_alloc_fn: ElemAllocF, |
| 1272 | + elem_dealloc_fn: ElemDeallocF, |
| 1273 | + ) -> Self |
| 1274 | + where |
| 1275 | + ElemAllocF: Fn(usize) -> *mut T, |
| 1276 | + { |
| 1277 | + Self { buf_ptr: elem_alloc_fn(len), capacity: len, elem_dealloc_fn } |
1276 | 1278 | }
|
1277 | 1279 | }
|
1278 | 1280 |
|
1279 |
| - impl<T, ElemAllocF, ElemDeallocF> Drop for BufGuard<T, ElemAllocF, ElemDeallocF> |
| 1281 | + impl<T, ElemDeallocF> Drop for BufGuard<T, ElemDeallocF> |
1280 | 1282 | where
|
1281 |
| - ElemAllocF: Fn(usize) -> *mut T, |
1282 | 1283 | ElemDeallocF: Fn(*mut T, usize),
|
1283 | 1284 | {
|
1284 | 1285 | fn drop(&mut self) {
|
|
0 commit comments