about summary refs log tree commit diff
path: root/src/libcollections
diff options
context:
space:
mode:
authorTobias Bucher <tobiasbucher5991@gmail.com>2016-02-16 16:00:38 +0100
committerTobias Bucher <tobiasbucher5991@gmail.com>2016-02-17 17:43:54 +0100
commit8fd746999041cf8baed0aa8ec72e9124c350bd0a (patch)
treee4311c6d8810e4a8e91aaa57e4a73a25cb43d1f1 /src/libcollections
parentb54770c24578311ad6cc782fcf1d0dc8cb41e997 (diff)
Implement `Clone` for `std::vec::IntoIter`
Diffstat (limited to 'src/libcollections')
-rw-r--r--src/libcollections/vec.rs12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index 270a01014c1..49c35520833 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -59,9 +59,10 @@
 
 #![stable(feature = "rust1", since = "1.0.0")]
 
-use alloc::raw_vec::RawVec;
 use alloc::boxed::Box;
 use alloc::heap::EMPTY;
+use alloc::raw_vec::RawVec;
+use borrow::ToOwned;
 use core::cmp::Ordering;
 use core::fmt;
 use core::hash::{self, Hash};
@@ -1633,6 +1634,15 @@ impl<T> DoubleEndedIterator for IntoIter<T> {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> ExactSizeIterator for IntoIter<T> {}
 
+#[stable(feature = "vec_into_iter_clone", since = "1.8.0")]
+impl<T: Clone> Clone for IntoIter<T> {
+    fn clone(&self) -> IntoIter<T> {
+        unsafe {
+            slice::from_raw_parts(self.ptr, self.len()).to_owned().into_iter()
+        }
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<T> Drop for IntoIter<T> {
     #[unsafe_destructor_blind_to_params]