Skip to content

Commit 40aea98

Browse files
Vec/VecDeque to use COOP_PREFERRED. WIP, NOT COMPILING. But: rustc doesn't die anymore.
1 parent 3ac82bd commit 40aea98

File tree

1 file changed

+7
-6
lines changed
  • library/alloc/src/collections/vec_deque

1 file changed

+7
-6
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ where
158158
}
159159

160160
#[stable(feature = "rust1", since = "1.0.0")]
161-
impl<T, const COOP_PREFERRED: bool = true> Default for VecDeque<T, Global, COOP_PREFERRED> {
161+
impl<T, A: Allocator, const COOP_PREFERRED: bool> Default for VecDeque<T, Global, COOP_PREFERRED> {
162162
/// Creates an empty deque.
163163
#[inline]
164164
fn default() -> VecDeque<T, Global, COOP_PREFERRED> {
@@ -547,7 +547,7 @@ where
547547
}
548548
}
549549

550-
impl<T, Global, const COOP_PREFERRED: bool> VecDeque<T, Global, COOP_PREFERRED>
550+
impl<T, A: Allocator, const COOP_PREFERRED: bool> VecDeque<T, A, COOP_PREFERRED>
551551
where
552552
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
553553
{
@@ -581,7 +581,7 @@ where
581581
#[inline]
582582
#[stable(feature = "rust1", since = "1.0.0")]
583583
#[must_use]
584-
pub fn with_capacity(capacity: usize) -> VecDeque<T, Global, COOP_PREFERRED> {
584+
pub fn with_capacity(capacity: usize) -> VecDeque<T, A, COOP_PREFERRED> {
585585
Self::with_capacity_in(capacity, Global)
586586
}
587587
}
@@ -2789,7 +2789,7 @@ where
27892789
}
27902790

27912791
#[stable(feature = "rust1", since = "1.0.0")]
2792-
impl<T, const COOP_PREFERRED: bool> FromIterator<T> for VecDeque<T, GlobalAlloc, COOP_PREFERRED>
2792+
impl<T, A: Allocator, const COOP_PREFERRED: bool> FromIterator<T> for VecDeque<T, A, COOP_PREFERRED>
27932793
where
27942794
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
27952795
{
@@ -2974,8 +2974,8 @@ where
29742974
}
29752975

29762976
#[stable(feature = "std_collections_from_array", since = "1.56.0")]
2977-
impl<T, const N: usize, const COOP_PREFERRED: bool> From<[T; N]>
2978-
for VecDeque<T, Global, COOP_PREFERRED>
2977+
impl<T, const N: usize, A: Allocator = Global, const COOP_PREFERRED: bool = DEFAULT_COOP_PREFERRED>
2978+
From<[T; N]> for VecDeque<T, A, COOP_PREFERRED>
29792979
where
29802980
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
29812981
{
@@ -2994,6 +2994,7 @@ where
29942994
if !<T>::IS_ZST {
29952995
// SAFETY: VecDeque::with_capacity ensures that there is enough capacity.
29962996
unsafe {
2997+
// @FIXME for COOP_PREFERRED:
29972998
ptr::copy_nonoverlapping(arr.as_ptr(), deq.ptr(), N);
29982999
}
29993000
}

0 commit comments

Comments
 (0)