aboutsummaryrefslogtreecommitdiff
path: root/libcollections/vec.rs
diff options
context:
space:
mode:
authorpravic <[email protected]>2016-04-29 21:16:15 +0300
committerpravic <[email protected]>2016-04-29 21:16:15 +0300
commit77e9a3167b4aaadf3583a0c1d1ee0d9e63c9a000 (patch)
tree710e445d56a1a582b8eff19b7b4b180276eae122 /libcollections/vec.rs
parenttweak: /driver option specifies /fixed:no implicitly as well (diff)
downloadkmd-env-rs-77e9a3167b4aaadf3583a0c1d1ee0d9e63c9a000.tar.xz
kmd-env-rs-77e9a3167b4aaadf3583a0c1d1ee0d9e63c9a000.zip
update libcore to 2016-04-29 nightly
Diffstat (limited to 'libcollections/vec.rs')
-rw-r--r--libcollections/vec.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/libcollections/vec.rs b/libcollections/vec.rs
index dde5cbb..58d4a4e 100644
--- a/libcollections/vec.rs
+++ b/libcollections/vec.rs
@@ -75,6 +75,7 @@ use core::ops;
use core::ptr;
use core::slice;
+use super::SpecExtend;
use super::range::RangeArgument;
/// A contiguous growable array type, written `Vec<T>` but pronounced 'vector.'
@@ -1390,10 +1391,22 @@ impl<'a, T> IntoIterator for &'a mut Vec<T> {
impl<T> Extend<T> for Vec<T> {
#[inline]
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I) {
+ <Self as SpecExtend<I>>::spec_extend(self, iter);
+ }
+}
+
+impl<I: IntoIterator> SpecExtend<I> for Vec<I::Item> {
+ default fn spec_extend(&mut self, iter: I) {
self.extend_desugared(iter.into_iter())
}
}
+impl<T> SpecExtend<Vec<T>> for Vec<T> {
+ fn spec_extend(&mut self, ref mut other: Vec<T>) {
+ self.append(other);
+ }
+}
+
impl<T> Vec<T> {
fn extend_desugared<I: Iterator<Item = T>>(&mut self, mut iterator: I) {
// This function should be the moral equivalent of: