about summary refs log tree commit diff
path: root/library/alloc
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2021-03-08 15:32:41 -0800
committerJosh Stone <jistone@redhat.com>2021-03-26 09:32:29 -0700
commit3b1f5e34620d6bfa32a127258e2c2d9f2f4d693b (patch)
tree65195beaa85d4c160440fb38aa940536040a010a /library/alloc
parentb362958453910169876686a839c6818fec2950c5 (diff)
downloadrust-3b1f5e34620d6bfa32a127258e2c2d9f2f4d693b.tar.gz
rust-3b1f5e34620d6bfa32a127258e2c2d9f2f4d693b.zip
Use iter::zip in library/
Diffstat (limited to 'library/alloc')
-rw-r--r--library/alloc/src/lib.rs1
-rw-r--r--library/alloc/src/vec/mod.rs9
2 files changed, 4 insertions, 6 deletions
diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs
index 40f2de8f70d..fb243100990 100644
--- a/library/alloc/src/lib.rs
+++ b/library/alloc/src/lib.rs
@@ -108,6 +108,7 @@
 // that the feature-gate isn't enabled. Ideally, it wouldn't check for the feature gate for docs
 // from other crates, but since this can only appear for lang items, it doesn't seem worth fixing.
 #![feature(intra_doc_pointers)]
+#![feature(iter_zip)]
 #![feature(lang_items)]
 #![feature(layout_for_ptr)]
 #![feature(maybe_uninit_ref)]
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs
index ff93c772b5b..708898ad2e7 100644
--- a/library/alloc/src/vec/mod.rs
+++ b/library/alloc/src/vec/mod.rs
@@ -58,7 +58,7 @@ use core::convert::TryFrom;
 use core::fmt;
 use core::hash::{Hash, Hasher};
 use core::intrinsics::{arith_offset, assume};
-use core::iter::FromIterator;
+use core::iter::{self, FromIterator};
 use core::marker::PhantomData;
 use core::mem::{self, ManuallyDrop, MaybeUninit};
 use core::ops::{self, Index, IndexMut, Range, RangeBounds};
@@ -2268,11 +2268,8 @@ impl<T: Clone, A: Allocator> ExtendFromWithinSpec for Vec<T, A> {
         // - caller guaratees that src is a valid index
         let to_clone = unsafe { this.get_unchecked(src) };
 
-        to_clone
-            .iter()
-            .cloned()
-            .zip(spare.iter_mut())
-            .map(|(src, dst)| dst.write(src))
+        iter::zip(to_clone, spare)
+            .map(|(src, dst)| dst.write(src.clone()))
             // Note:
             // - Element was just initialized with `MaybeUninit::write`, so it's ok to increace len
             // - len is increased after each element to prevent leaks (see issue #82533)