Skip to content

Commit ac054b9

Browse files
Fixing A and COOP_PREFERRED generics. WIP..
1 parent e3a5fb6 commit ac054b9

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ where
2222
}
2323
}
2424

25-
impl<T, A: Allocator, const COOP_PREFERRED: bool> SpecFromIter<T, crate::vec::IntoIter<T>>
25+
impl<T, A: Allocator, const COOP_PREFERRED: bool> SpecFromIter<T, crate::vec::IntoIter<T, A, COOP_PREFERRED>>
2626
for VecDeque<T, A, COOP_PREFERRED>
2727
where
2828
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
2929
{
3030
#[inline]
31-
fn spec_from_iter(iterator: crate::vec::IntoIter<T>) -> Self {
31+
fn spec_from_iter(iterator: crate::vec::IntoIter<T, A, COOP_PREFERRED>) -> Self {
3232
iterator.into_vecdeque()
3333
}
3434
}
3535

36-
impl<T, A: Allocator, const COOP_PREFERRED: bool> SpecFromIter<T, IntoIter<T>>
36+
impl<T, A: Allocator, const COOP_PREFERRED: bool> SpecFromIter<T, IntoIter<T, A, COOP_PREFERRED>>
3737
for VecDeque<T, A, COOP_PREFERRED>
3838
where
3939
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,

library/alloc/src/vec/in_place_collect.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,11 @@
137137
//! }
138138
//! vec.truncate(write_idx);
139139
//! ```
140+
use core::alloc::{self, Allocator};
140141
use core::iter::{InPlaceIterable, SourceIter, TrustedRandomAccessNoCoerce};
141142
use core::mem::{self, ManuallyDrop, SizedTypeProperties};
142143
use core::ptr::{self};
143144

144-
use crate::Global;
145-
use crate::DEFAULT_COOP_PREFERRED;
146-
147145
use super::{InPlaceDrop, InPlaceDstBufDrop, SpecFromIter, SpecFromIterNested, Vec};
148146

149147
/// Specialization marker for collecting an iterator pipeline into a Vec while reusing the
@@ -154,9 +152,11 @@ pub(super) trait InPlaceIterableMarker {}
154152
impl<T> InPlaceIterableMarker for T where T: InPlaceIterable {}
155153

156154
#[allow(unused_braces)]
157-
impl<T, I> SpecFromIter<T, I> for Vec<T, Global, {DEFAULT_COOP_PREFERRED!()}>
155+
impl<T, I, A: Allocator, const COOP_PREFERRED: bool> SpecFromIter<T, I> for Vec<T, A, COOP_PREFERRED>
158156
where
159157
I: Iterator<Item = T> + SourceIter<Source: AsVecIntoIter> + InPlaceIterableMarker,
158+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
159+
160160
{
161161
default fn from_iter(mut iterator: I) -> Self {
162162
// See "Layout constraints" section in the module documentation. We rely on const

library/alloc/src/vec/spec_from_iter.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1+
use core::alloc::{self, Allocator};
12
use core::mem::ManuallyDrop;
23
use core::ptr::{self};
3-
use crate::Global;
4-
use crate::DEFAULT_COOP_PREFERRED;
54

65
use super::{IntoIter, SpecExtend, SpecFromIterNested, Vec};
76

@@ -28,17 +27,21 @@ pub(super) trait SpecFromIter<T, I> {
2827
}
2928

3029
#[allow(unused_braces)]
31-
impl<T, I> SpecFromIter<T, I> for Vec<T, Global, {DEFAULT_COOP_PREFERRED!()}>
30+
impl<T, I, A: Allocator, const COOP_PREFERRED: bool> SpecFromIter<T, I> for Vec<T, A, COOP_PREFERRED>
3231
where
3332
I: Iterator<Item = T>,
33+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
3434
{
3535
default fn from_iter(iterator: I) -> Self {
3636
SpecFromIterNested::from_iter(iterator)
3737
}
3838
}
3939

4040
#[allow(unused_braces)]
41-
impl<T> SpecFromIter<T, IntoIter<T>> for Vec<T, Global, {DEFAULT_COOP_PREFERRED!()}> {
41+
impl<T, A: Allocator, const COOP_PREFERRED: bool> SpecFromIter<T, IntoIter<T>> for Vec<T, A, COOP_PREFERRED>
42+
where
43+
[(); alloc::co_alloc_metadata_num_slots_with_preference::<A>(COOP_PREFERRED)]:,
44+
{
4245
fn from_iter(iterator: IntoIter<T>) -> Self {
4346
// A common case is passing a vector into a function which immediately
4447
// re-collects into a vector. We can short circuit this if the IntoIter

0 commit comments

Comments
 (0)