Skip to content

Commit 6264c24

Browse files
Vec/VecDeque to use COOP_PREFERRED. WIP, NOT COMPILING. But: rustc doesn't die anymore.
1 parent 3847e14 commit 6264c24

File tree

1 file changed

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

1 file changed

+8
-7
lines changed

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

+8-7
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
{
@@ -564,7 +564,7 @@ where
564564
#[inline]
565565
#[stable(feature = "rust1", since = "1.0.0")]
566566
#[must_use]
567-
pub fn new() -> VecDeque<T, Global, COOP_PREFERRED> {
567+
pub fn new() -> VecDeque<T, A, COOP_PREFERRED> {
568568
VecDeque::new_in(Global)
569569
}
570570

@@ -580,7 +580,7 @@ where
580580
#[inline]
581581
#[stable(feature = "rust1", since = "1.0.0")]
582582
#[must_use]
583-
pub fn with_capacity(capacity: usize) -> VecDeque<T, Global, COOP_PREFERRED> {
583+
pub fn with_capacity(capacity: usize) -> VecDeque<T, A, COOP_PREFERRED> {
584584
Self::with_capacity_in(capacity, Global)
585585
}
586586
}
@@ -2788,7 +2788,7 @@ where
27882788
}
27892789

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

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

0 commit comments

Comments
 (0)