about summary refs log tree commit diff
path: root/src/libcollections
diff options
context:
space:
mode:
authorJohannes Oertel <johannes.oertel@uni-due.de>2015-06-03 12:38:42 +0200
committerJohannes Oertel <johannes.oertel@uni-due.de>2015-06-08 12:05:33 +0200
commitb36ed7d2edf68453c0344eb3cd55281e48c96ecb (patch)
treee1bda74459df66821d1182fb397048f24e3829fa /src/libcollections
parenta5979be9fefe671fa81ec70720234602f8112bec (diff)
downloadrust-b36ed7d2edf68453c0344eb3cd55281e48c96ecb.tar.gz
rust-b36ed7d2edf68453c0344eb3cd55281e48c96ecb.zip
Implement RFC 839
Closes #25976.
Diffstat (limited to 'src/libcollections')
-rw-r--r--src/libcollections/binary_heap.rs7
-rw-r--r--src/libcollections/bit.rs14
-rw-r--r--src/libcollections/btree/map.rs7
-rw-r--r--src/libcollections/btree/set.rs7
-rw-r--r--src/libcollections/enum_set.rs7
-rw-r--r--src/libcollections/linked_list.rs7
-rw-r--r--src/libcollections/string.rs7
-rw-r--r--src/libcollections/vec.rs7
-rw-r--r--src/libcollections/vec_deque.rs7
-rw-r--r--src/libcollections/vec_map.rs7
10 files changed, 77 insertions, 0 deletions
diff --git a/src/libcollections/binary_heap.rs b/src/libcollections/binary_heap.rs
index 00e4002f82f..97bdd8e6a6e 100644
--- a/src/libcollections/binary_heap.rs
+++ b/src/libcollections/binary_heap.rs
@@ -760,3 +760,10 @@ impl<T: Ord> Extend<T> for BinaryHeap<T> {
         }
     }
 }
+
+#[stable(feature = "extend_ref", since = "1.2.0")]
+impl<'a, T: 'a + Ord + Copy> Extend<&'a T> for BinaryHeap<T> {
+    fn extend<I: IntoIterator<Item=&'a T>>(&mut self, iter: I) {
+        self.extend(iter.into_iter().cloned());
+    }
+}
diff --git a/src/libcollections/bit.rs b/src/libcollections/bit.rs
index c06cbdb4179..37797425e7a 100644
--- a/src/libcollections/bit.rs
+++ b/src/libcollections/bit.rs
@@ -1070,6 +1070,13 @@ impl Extend<bool> for BitVec {
     }
 }
 
+#[stable(feature = "extend_ref", since = "1.2.0")]
+impl<'a> Extend<&'a bool> for BitVec {
+    fn extend<I: IntoIterator<Item=&'a bool>>(&mut self, iter: I) {
+        self.extend(iter.into_iter().cloned());
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl Clone for BitVec {
     #[inline]
@@ -1278,6 +1285,13 @@ impl Extend<usize> for BitSet {
     }
 }
 
+#[stable(feature = "extend_ref", since = "1.2.0")]
+impl<'a> Extend<&'a usize> for BitSet {
+    fn extend<I: IntoIterator<Item=&'a usize>>(&mut self, iter: I) {
+        self.extend(iter.into_iter().cloned());
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl PartialOrd for BitSet {
     #[inline]
diff --git a/src/libcollections/btree/map.rs b/src/libcollections/btree/map.rs
index 11f16e2f400..c7c336e38a1 100644
--- a/src/libcollections/btree/map.rs
+++ b/src/libcollections/btree/map.rs
@@ -879,6 +879,13 @@ impl<K: Ord, V> Extend<(K, V)> for BTreeMap<K, V> {
     }
 }
 
+#[stable(feature = "extend_ref", since = "1.2.0")]
+impl<'a, K: Ord + Copy, V: Copy> Extend<(&'a K, &'a V)> for BTreeMap<K, V> {
+    fn extend<I: IntoIterator<Item=(&'a K, &'a V)>>(&mut self, iter: I) {
+        self.extend(iter.into_iter().map(|(&key, &value)| (key, value)));
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<K: Hash, V: Hash> Hash for BTreeMap<K, V> {
     fn hash<H: Hasher>(&self, state: &mut H) {
diff --git a/src/libcollections/btree/set.rs b/src/libcollections/btree/set.rs
index a3b9320e2b5..ec6c5e63e2d 100644
--- a/src/libcollections/btree/set.rs
+++ b/src/libcollections/btree/set.rs
@@ -509,6 +509,13 @@ impl<T: Ord> Extend<T> for BTreeSet<T> {
     }
 }
 
+#[stable(feature = "extend_ref", since = "1.2.0")]
+impl<'a, T: 'a + Ord + Copy> Extend<&'a T> for BTreeSet<T> {
+    fn extend<I: IntoIterator<Item=&'a T>>(&mut self, iter: I) {
+        self.extend(iter.into_iter().cloned());
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: Ord> Default for BTreeSet<T> {
     #[stable(feature = "rust1", since = "1.0.0")]
diff --git a/src/libcollections/enum_set.rs b/src/libcollections/enum_set.rs
index e6cdb88d3e1..ad90f9f1caa 100644
--- a/src/libcollections/enum_set.rs
+++ b/src/libcollections/enum_set.rs
@@ -288,3 +288,10 @@ impl<E:CLike> Extend<E> for EnumSet<E> {
         }
     }
 }
+
+#[stable(feature = "extend_ref", since = "1.2.0")]
+impl<'a, E: 'a + CLike + Copy> Extend<&'a E> for EnumSet<E> {
+    fn extend<I: IntoIterator<Item=&'a E>>(&mut self, iter: I) {
+        self.extend(iter.into_iter().cloned());
+    }
+}
diff --git a/src/libcollections/linked_list.rs b/src/libcollections/linked_list.rs
index 61ebf7f6df9..e47892f4454 100644
--- a/src/libcollections/linked_list.rs
+++ b/src/libcollections/linked_list.rs
@@ -871,6 +871,13 @@ impl<A> Extend<A> for LinkedList<A> {
     }
 }
 
+#[stable(feature = "extend_ref", since = "1.2.0")]
+impl<'a, T: 'a + Copy> Extend<&'a T> for LinkedList<T> {
+    fn extend<I: IntoIterator<Item=&'a T>>(&mut self, iter: I) {
+        self.extend(iter.into_iter().cloned());
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<A: PartialEq> PartialEq for LinkedList<A> {
     fn eq(&self, other: &LinkedList<A>) -> bool {
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs
index c328a58f077..d0f59cbf047 100644
--- a/src/libcollections/string.rs
+++ b/src/libcollections/string.rs
@@ -793,6 +793,13 @@ impl Extend<char> for String {
     }
 }
 
+#[stable(feature = "extend_ref", since = "1.2.0")]
+impl<'a> Extend<&'a char> for String {
+    fn extend<I: IntoIterator<Item=&'a char>>(&mut self, iter: I) {
+        self.extend(iter.into_iter().cloned());
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a> Extend<&'a str> for String {
     fn extend<I: IntoIterator<Item=&'a str>>(&mut self, iterable: I) {
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index 8dacfa53bc9..7ce4bd546b9 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -1578,6 +1578,13 @@ impl<T> Extend<T> for Vec<T> {
     }
 }
 
+#[stable(feature = "extend_ref", since = "1.2.0")]
+impl<'a, T: 'a + Copy> Extend<&'a T> for Vec<T> {
+    fn extend<I: IntoIterator<Item=&'a T>>(&mut self, iter: I) {
+        self.extend(iter.into_iter().cloned());
+    }
+}
+
 __impl_slice_eq1! { Vec<A>, Vec<B> }
 __impl_slice_eq1! { Vec<A>, &'b [B] }
 __impl_slice_eq1! { Vec<A>, &'b mut [B] }
diff --git a/src/libcollections/vec_deque.rs b/src/libcollections/vec_deque.rs
index 0bc42bd2c7e..88d0a96b78c 100644
--- a/src/libcollections/vec_deque.rs
+++ b/src/libcollections/vec_deque.rs
@@ -1785,6 +1785,13 @@ impl<A> Extend<A> for VecDeque<A> {
     }
 }
 
+#[stable(feature = "extend_ref", since = "1.2.0")]
+impl<'a, T: 'a + Copy> Extend<&'a T> for VecDeque<T> {
+    fn extend<I: IntoIterator<Item=&'a T>>(&mut self, iter: I) {
+        self.extend(iter.into_iter().cloned());
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T: fmt::Debug> fmt::Debug for VecDeque<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
diff --git a/src/libcollections/vec_map.rs b/src/libcollections/vec_map.rs
index aa0ab41b745..8180f1d56df 100644
--- a/src/libcollections/vec_map.rs
+++ b/src/libcollections/vec_map.rs
@@ -828,6 +828,13 @@ impl<V> Extend<(usize, V)> for VecMap<V> {
     }
 }
 
+#[stable(feature = "extend_ref", since = "1.2.0")]
+impl<'a, V: Copy> Extend<(usize, &'a V)> for VecMap<V> {
+    fn extend<I: IntoIterator<Item=(usize, &'a V)>>(&mut self, iter: I) {
+        self.extend(iter.into_iter().map(|(key, &value)| (key, value)));
+    }
+}
+
 impl<V> Index<usize> for VecMap<V> {
     type Output = V;