about summary refs log tree commit diff
path: root/library/alloc/src/vec/into_iter.rs
diff options
context:
space:
mode:
authorThe 8472 <git@infinite-source.de>2022-07-30 01:48:16 +0200
committerThe 8472 <git@infinite-source.de>2023-02-28 21:00:00 +0100
commit05c7330ca03650bbcb6a55f5fa490b3bb03c1940 (patch)
treeb7ace4e112ca9e379342f60cd877fbb40211b400 /library/alloc/src/vec/into_iter.rs
parent31f858d9a511f24fedb8ed997b28304fec809630 (diff)
downloadrust-05c7330ca03650bbcb6a55f5fa490b3bb03c1940.tar.gz
rust-05c7330ca03650bbcb6a55f5fa490b3bb03c1940.zip
Implement Default for some alloc/core iterators
This way one can `mem::take()` them out of structs or #[derive(Default)] on structs containing them.

These changes will be insta-stable.
Diffstat (limited to 'library/alloc/src/vec/into_iter.rs')
-rw-r--r--library/alloc/src/vec/into_iter.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/library/alloc/src/vec/into_iter.rs b/library/alloc/src/vec/into_iter.rs
index 37966007eb7..2be484c3dd4 100644
--- a/library/alloc/src/vec/into_iter.rs
+++ b/library/alloc/src/vec/into_iter.rs
@@ -347,6 +347,13 @@ impl<T, A: Allocator> FusedIterator for IntoIter<T, A> {}
 #[unstable(feature = "trusted_len", issue = "37572")]
 unsafe impl<T, A: Allocator> TrustedLen for IntoIter<T, A> {}
 
+#[stable(feature = "default_iters", since = "CURRENT_RUSTC_VERSION")]
+impl<T> Default for IntoIter<T> {
+    fn default() -> Self {
+        super::Vec::new().into_iter()
+    }
+}
+
 #[doc(hidden)]
 #[unstable(issue = "none", feature = "std_internals")]
 #[rustc_unsafe_specialization_marker]