Skip to content

Commit 219edc7

Browse files
Vec/VecDeque to use COOP_PREFERRED. WIP, NOT COMPILING. But: rustc doesn't die anymore.
1 parent 1549f7b commit 219edc7

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
}
@@ -2791,7 +2791,7 @@ where
27912791
}
27922792

27932793
#[stable(feature = "rust1", since = "1.0.0")]
2794-
impl<T, const COOP_PREFERRED: bool> FromIterator<T> for VecDeque<T, GlobalAlloc, COOP_PREFERRED>
2794+
impl<T, A: Allocator, const COOP_PREFERRED: bool> FromIterator<T> for VecDeque<T, A, COOP_PREFERRED>
27952795
where
27962796
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
27972797
{
@@ -2976,8 +2976,8 @@ where
29762976
}
29772977

29782978
#[stable(feature = "std_collections_from_array", since = "1.56.0")]
2979-
impl<T, const N: usize, const COOP_PREFERRED: bool> From<[T; N]>
2980-
for VecDeque<T, Global, COOP_PREFERRED>
2979+
impl<T, const N: usize, A: Allocator = Global, const COOP_PREFERRED: bool = DEFAULT_COOP_PREFERRED>
2980+
From<[T; N]> for VecDeque<T, A, COOP_PREFERRED>
29812981
where
29822982
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
29832983
{
@@ -2996,6 +2996,7 @@ where
29962996
if !<T>::IS_ZST {
29972997
// SAFETY: VecDeque::with_capacity ensures that there is enough capacity.
29982998
unsafe {
2999+
// @FIXME for COOP_PREFERRED:
29993000
ptr::copy_nonoverlapping(arr.as_ptr(), deq.ptr(), N);
30003001
}
30013002
}

0 commit comments

Comments
 (0)