Skip to content

Commit 1d47474

Browse files
CoAlloc: Added CO_ALLOC_PREF to two Guard structs inside vec_deque::into_iter
1 parent a84b78c commit 1d47474

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

library/alloc/src/collections/vec_deque/into_iter.rs

+20-8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
use core::iter::{FusedIterator, TrustedLen};
2-
use core::{alloc, array, fmt, mem::MaybeUninit, ops::Try, ptr};
31
use crate::co_alloc::CoAllocPref;
2+
use core::iter::{FusedIterator, TrustedLen};
3+
use core::{array, fmt, mem::MaybeUninit, ops::Try, ptr};
44

55
use crate::alloc::{Allocator, Global};
66

@@ -93,13 +93,19 @@ where
9393
F: FnMut(B, Self::Item) -> R,
9494
R: Try<Output = B>,
9595
{
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>,
98101
// `consumed <= deque.len` always holds.
99102
consumed: usize,
100103
}
101104

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+
{
103109
fn drop(&mut self) {
104110
self.deque.len -= self.consumed;
105111
self.deque.head = self.deque.to_physical_idx(self.consumed);
@@ -221,13 +227,19 @@ where
221227
F: FnMut(B, Self::Item) -> R,
222228
R: Try<Output = B>,
223229
{
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>,
226235
// `consumed <= deque.len` always holds.
227236
consumed: usize,
228237
}
229238

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+
{
231243
fn drop(&mut self) {
232244
self.deque.len -= self.consumed;
233245
}

0 commit comments

Comments
 (0)