Skip to content

Commit 4a397dd

Browse files
committed
Auto merge of #25989 - jooert:implement_rfc839, r=Gankro
I had to use `impl<'a, V: Copy> Extend<(usize, &'a V)> for VecMap<V>` instead of `impl<'a, V: Copy> Extend<(&'a usize, &'a V)> for VecMap<V>` as that's what is needed for doing ```rust let mut a = VecMap::new(); let b = VecMap::new(); b.insert(1, "foo"); a.extend(&b) ``` I can squash the commits after review. r? @gankro
2 parents 61c43b4 + b36ed7d commit 4a397dd

File tree

22 files changed

+291
-1
lines changed

22 files changed

+291
-1
lines changed

src/libcollections/binary_heap.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,3 +760,10 @@ impl<T: Ord> Extend<T> for BinaryHeap<T> {
760760
}
761761
}
762762
}
763+
764+
#[stable(feature = "extend_ref", since = "1.2.0")]
765+
impl<'a, T: 'a + Ord + Copy> Extend<&'a T> for BinaryHeap<T> {
766+
fn extend<I: IntoIterator<Item=&'a T>>(&mut self, iter: I) {
767+
self.extend(iter.into_iter().cloned());
768+
}
769+
}

src/libcollections/bit.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,6 +1070,13 @@ impl Extend<bool> for BitVec {
10701070
}
10711071
}
10721072

1073+
#[stable(feature = "extend_ref", since = "1.2.0")]
1074+
impl<'a> Extend<&'a bool> for BitVec {
1075+
fn extend<I: IntoIterator<Item=&'a bool>>(&mut self, iter: I) {
1076+
self.extend(iter.into_iter().cloned());
1077+
}
1078+
}
1079+
10731080
#[stable(feature = "rust1", since = "1.0.0")]
10741081
impl Clone for BitVec {
10751082
#[inline]
@@ -1278,6 +1285,13 @@ impl Extend<usize> for BitSet {
12781285
}
12791286
}
12801287

1288+
#[stable(feature = "extend_ref", since = "1.2.0")]
1289+
impl<'a> Extend<&'a usize> for BitSet {
1290+
fn extend<I: IntoIterator<Item=&'a usize>>(&mut self, iter: I) {
1291+
self.extend(iter.into_iter().cloned());
1292+
}
1293+
}
1294+
12811295
#[stable(feature = "rust1", since = "1.0.0")]
12821296
impl PartialOrd for BitSet {
12831297
#[inline]

src/libcollections/btree/map.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -879,6 +879,13 @@ impl<K: Ord, V> Extend<(K, V)> for BTreeMap<K, V> {
879879
}
880880
}
881881

882+
#[stable(feature = "extend_ref", since = "1.2.0")]
883+
impl<'a, K: Ord + Copy, V: Copy> Extend<(&'a K, &'a V)> for BTreeMap<K, V> {
884+
fn extend<I: IntoIterator<Item=(&'a K, &'a V)>>(&mut self, iter: I) {
885+
self.extend(iter.into_iter().map(|(&key, &value)| (key, value)));
886+
}
887+
}
888+
882889
#[stable(feature = "rust1", since = "1.0.0")]
883890
impl<K: Hash, V: Hash> Hash for BTreeMap<K, V> {
884891
fn hash<H: Hasher>(&self, state: &mut H) {

src/libcollections/btree/set.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,13 @@ impl<T: Ord> Extend<T> for BTreeSet<T> {
509509
}
510510
}
511511

512+
#[stable(feature = "extend_ref", since = "1.2.0")]
513+
impl<'a, T: 'a + Ord + Copy> Extend<&'a T> for BTreeSet<T> {
514+
fn extend<I: IntoIterator<Item=&'a T>>(&mut self, iter: I) {
515+
self.extend(iter.into_iter().cloned());
516+
}
517+
}
518+
512519
#[stable(feature = "rust1", since = "1.0.0")]
513520
impl<T: Ord> Default for BTreeSet<T> {
514521
#[stable(feature = "rust1", since = "1.0.0")]

src/libcollections/enum_set.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,10 @@ impl<E:CLike> Extend<E> for EnumSet<E> {
288288
}
289289
}
290290
}
291+
292+
#[stable(feature = "extend_ref", since = "1.2.0")]
293+
impl<'a, E: 'a + CLike + Copy> Extend<&'a E> for EnumSet<E> {
294+
fn extend<I: IntoIterator<Item=&'a E>>(&mut self, iter: I) {
295+
self.extend(iter.into_iter().cloned());
296+
}
297+
}

src/libcollections/linked_list.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,6 +904,13 @@ impl<A> Extend<A> for LinkedList<A> {
904904
}
905905
}
906906

907+
#[stable(feature = "extend_ref", since = "1.2.0")]
908+
impl<'a, T: 'a + Copy> Extend<&'a T> for LinkedList<T> {
909+
fn extend<I: IntoIterator<Item=&'a T>>(&mut self, iter: I) {
910+
self.extend(iter.into_iter().cloned());
911+
}
912+
}
913+
907914
#[stable(feature = "rust1", since = "1.0.0")]
908915
impl<A: PartialEq> PartialEq for LinkedList<A> {
909916
fn eq(&self, other: &LinkedList<A>) -> bool {

src/libcollections/string.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -793,6 +793,13 @@ impl Extend<char> for String {
793793
}
794794
}
795795

796+
#[stable(feature = "extend_ref", since = "1.2.0")]
797+
impl<'a> Extend<&'a char> for String {
798+
fn extend<I: IntoIterator<Item=&'a char>>(&mut self, iter: I) {
799+
self.extend(iter.into_iter().cloned());
800+
}
801+
}
802+
796803
#[stable(feature = "rust1", since = "1.0.0")]
797804
impl<'a> Extend<&'a str> for String {
798805
fn extend<I: IntoIterator<Item=&'a str>>(&mut self, iterable: I) {

src/libcollections/vec.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,13 @@ impl<T> Extend<T> for Vec<T> {
15781578
}
15791579
}
15801580

1581+
#[stable(feature = "extend_ref", since = "1.2.0")]
1582+
impl<'a, T: 'a + Copy> Extend<&'a T> for Vec<T> {
1583+
fn extend<I: IntoIterator<Item=&'a T>>(&mut self, iter: I) {
1584+
self.extend(iter.into_iter().cloned());
1585+
}
1586+
}
1587+
15811588
__impl_slice_eq1! { Vec<A>, Vec<B> }
15821589
__impl_slice_eq1! { Vec<A>, &'b [B] }
15831590
__impl_slice_eq1! { Vec<A>, &'b mut [B] }

src/libcollections/vec_deque.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,6 +1785,13 @@ impl<A> Extend<A> for VecDeque<A> {
17851785
}
17861786
}
17871787

1788+
#[stable(feature = "extend_ref", since = "1.2.0")]
1789+
impl<'a, T: 'a + Copy> Extend<&'a T> for VecDeque<T> {
1790+
fn extend<I: IntoIterator<Item=&'a T>>(&mut self, iter: I) {
1791+
self.extend(iter.into_iter().cloned());
1792+
}
1793+
}
1794+
17881795
#[stable(feature = "rust1", since = "1.0.0")]
17891796
impl<T: fmt::Debug> fmt::Debug for VecDeque<T> {
17901797
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {

src/libcollections/vec_map.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,13 @@ impl<V> Extend<(usize, V)> for VecMap<V> {
828828
}
829829
}
830830

831+
#[stable(feature = "extend_ref", since = "1.2.0")]
832+
impl<'a, V: Copy> Extend<(usize, &'a V)> for VecMap<V> {
833+
fn extend<I: IntoIterator<Item=(usize, &'a V)>>(&mut self, iter: I) {
834+
self.extend(iter.into_iter().map(|(key, &value)| (key, value)));
835+
}
836+
}
837+
831838
impl<V> Index<usize> for VecMap<V> {
832839
type Output = V;
833840

0 commit comments

Comments
 (0)