|
1 | | -use core::iter::{FusedIterator, TrustedLen}; |
2 | | -use core::{alloc, array, fmt, mem::MaybeUninit, ops::Try, ptr}; |
3 | 1 | use crate::co_alloc::CoAllocPref; |
| 2 | +use core::iter::{FusedIterator, TrustedLen}; |
| 3 | +use core::{array, fmt, mem::MaybeUninit, ops::Try, ptr}; |
4 | 4 |
|
5 | 5 | use crate::alloc::{Allocator, Global}; |
6 | 6 |
|
@@ -93,13 +93,19 @@ where |
93 | 93 | F: FnMut(B, Self::Item) -> R, |
94 | 94 | R: Try<Output = B>, |
95 | 95 | { |
96 | | - struct Guard<'a, T, A: Allocator> { |
97 | | - deque: &'a mut VecDeque<T, A>, |
| 96 | + struct Guard<'a, T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> |
| 97 | + where |
| 98 | + [(); { crate::meta_num_slots!(A, CO_ALLOC_PREF) }]:, |
| 99 | + { |
| 100 | + deque: &'a mut VecDeque<T, A, CO_ALLOC_PREF>, |
98 | 101 | // `consumed <= deque.len` always holds. |
99 | 102 | consumed: usize, |
100 | 103 | } |
101 | 104 |
|
102 | | - impl<'a, T, A: Allocator> Drop for Guard<'a, T, A> { |
| 105 | + impl<'a, T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> Drop for Guard<'a, T, A, CO_ALLOC_PREF> |
| 106 | + where |
| 107 | + [(); { crate::meta_num_slots!(A, CO_ALLOC_PREF) }]:, |
| 108 | + { |
103 | 109 | fn drop(&mut self) { |
104 | 110 | self.deque.len -= self.consumed; |
105 | 111 | self.deque.head = self.deque.to_physical_idx(self.consumed); |
@@ -221,13 +227,19 @@ where |
221 | 227 | F: FnMut(B, Self::Item) -> R, |
222 | 228 | R: Try<Output = B>, |
223 | 229 | { |
224 | | - struct Guard<'a, T, A: Allocator> { |
225 | | - deque: &'a mut VecDeque<T, A>, |
| 230 | + struct Guard<'a, T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> |
| 231 | + where |
| 232 | + [(); { crate::meta_num_slots!(A, CO_ALLOC_PREF) }]:, |
| 233 | + { |
| 234 | + deque: &'a mut VecDeque<T, A, CO_ALLOC_PREF>, |
226 | 235 | // `consumed <= deque.len` always holds. |
227 | 236 | consumed: usize, |
228 | 237 | } |
229 | 238 |
|
230 | | - impl<'a, T, A: Allocator> Drop for Guard<'a, T, A> { |
| 239 | + impl<'a, T, A: Allocator, const CO_ALLOC_PREF: CoAllocPref> Drop for Guard<'a, T, A, CO_ALLOC_PREF> |
| 240 | + where |
| 241 | + [(); { crate::meta_num_slots!(A, CO_ALLOC_PREF) }]:, |
| 242 | + { |
231 | 243 | fn drop(&mut self) { |
232 | 244 | self.deque.len -= self.consumed; |
233 | 245 | } |
|
0 commit comments