make specialization of Vec::extend and VecDeque::extend_front work for vec::IntoIter with any Allocator, not just Global
This commit is contained in:
parent
2848c2ebe9
commit
9a170fedd7
2 changed files with 10 additions and 8 deletions
|
|
@ -77,8 +77,8 @@ where
|
|||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
impl<T, A: Allocator> SpecExtend<T, vec::IntoIter<T>> for VecDeque<T, A> {
|
||||
fn spec_extend(&mut self, mut iterator: vec::IntoIter<T>) {
|
||||
impl<T, A1: Allocator, A2: Allocator> SpecExtend<T, vec::IntoIter<T, A2>> for VecDeque<T, A1> {
|
||||
fn spec_extend(&mut self, mut iterator: vec::IntoIter<T, A2>) {
|
||||
let slice = iterator.as_slice();
|
||||
self.reserve(slice.len());
|
||||
|
||||
|
|
@ -153,9 +153,9 @@ where
|
|||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
impl<T, A: Allocator> SpecExtendFront<T, vec::IntoIter<T>> for VecDeque<T, A> {
|
||||
impl<T, A1: Allocator, A2: Allocator> SpecExtendFront<T, vec::IntoIter<T, A2>> for VecDeque<T, A1> {
|
||||
#[track_caller]
|
||||
fn spec_extend_front(&mut self, mut iterator: vec::IntoIter<T>) {
|
||||
fn spec_extend_front(&mut self, mut iterator: vec::IntoIter<T, A2>) {
|
||||
let slice = iterator.as_slice();
|
||||
// SAFETY: elements in the slice are forgotten after this call
|
||||
unsafe { prepend_reversed(self, slice) };
|
||||
|
|
@ -164,9 +164,11 @@ impl<T, A: Allocator> SpecExtendFront<T, vec::IntoIter<T>> for VecDeque<T, A> {
|
|||
}
|
||||
|
||||
#[cfg(not(test))]
|
||||
impl<T, A: Allocator> SpecExtendFront<T, Rev<vec::IntoIter<T>>> for VecDeque<T, A> {
|
||||
impl<T, A1: Allocator, A2: Allocator> SpecExtendFront<T, Rev<vec::IntoIter<T, A2>>>
|
||||
for VecDeque<T, A1>
|
||||
{
|
||||
#[track_caller]
|
||||
fn spec_extend_front(&mut self, iterator: Rev<vec::IntoIter<T>>) {
|
||||
fn spec_extend_front(&mut self, iterator: Rev<vec::IntoIter<T, A2>>) {
|
||||
let mut iterator = iterator.into_inner();
|
||||
let slice = iterator.as_slice();
|
||||
// SAFETY: elements in the slice are forgotten after this call
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<T, A: Allocator> SpecExtend<T, IntoIter<T>> for Vec<T, A> {
|
||||
fn spec_extend(&mut self, mut iterator: IntoIter<T>) {
|
||||
impl<T, A1: Allocator, A2: Allocator> SpecExtend<T, IntoIter<T, A2>> for Vec<T, A1> {
|
||||
fn spec_extend(&mut self, mut iterator: IntoIter<T, A2>) {
|
||||
unsafe {
|
||||
self.append_elements(iterator.as_slice() as _);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue