Skip to content

Commit 75e3607

Browse files
committed
specialize Extend for Vec with IntoIter
1 parent fa332c9 commit 75e3607

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/libcollections/vec.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1681,7 +1681,7 @@ impl<T, I> SpecExtend<T, I> for Vec<T>
16811681
vector
16821682
}
16831683

1684-
fn spec_extend(&mut self, iterator: I) {
1684+
default fn spec_extend(&mut self, iterator: I) {
16851685
// This is the case for a TrustedLen iterator.
16861686
let (low, high) = iterator.size_hint();
16871687
if let Some(high_value) = high {
@@ -1728,6 +1728,14 @@ impl<T> SpecExtend<T, IntoIter<T>> for Vec<T> {
17281728
}
17291729
}
17301730

1731+
impl<T> SpecExtend<T, IntoIter<T>> for Vec<T>
1732+
where T: Copy,
1733+
{
1734+
fn spec_extend(&mut self, iterator: IntoIter<T>) {
1735+
self.spec_extend(iterator.as_slice());
1736+
}
1737+
}
1738+
17311739
impl<'a, T: 'a, I> SpecExtend<&'a T, I> for Vec<T>
17321740
where I: Iterator<Item=&'a T>,
17331741
T: Clone,

0 commit comments

Comments
 (0)