about summary refs log tree commit diff
path: root/library/core/src/array
diff options
context:
space:
mode:
authorLukas Kalbertodt <lukas.kalbertodt@gmail.com>2019-10-25 17:25:58 +0200
committerJosh Stone <jistone@redhat.com>2021-04-16 11:12:01 -0700
commit32aaea9c8fb99a94e6b289498a348459357c392f (patch)
tree5bf663a77244ca48ae1083580d8dc6a415cd3034 /library/core/src/array
parentb79af2fcde91abeae805c2dbccfdbf7114bfd47b (diff)
downloadrust-32aaea9c8fb99a94e6b289498a348459357c392f.tar.gz
rust-32aaea9c8fb99a94e6b289498a348459357c392f.zip
Add `IntoIterator` impl `for [T; N]` (arrays by value)
Diffstat (limited to 'library/core/src/array')
-rw-r--r--library/core/src/array/mod.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/library/core/src/array/mod.rs b/library/core/src/array/mod.rs
index b6ce825e247..bd6f35edfac 100644
--- a/library/core/src/array/mod.rs
+++ b/library/core/src/array/mod.rs
@@ -155,6 +155,16 @@ impl<T: fmt::Debug, const N: usize> fmt::Debug for [T; N] {
     }
 }
 
+#[stable(feature = "array_into_iter_impl", since = "1.53.0")]
+impl<T, const N: usize> IntoIterator for [T; N] {
+    type Item = T;
+    type IntoIter = IntoIter<T, N>;
+
+    fn into_iter(self) -> Self::IntoIter {
+        IntoIter::new(self)
+    }
+}
+
 #[stable(feature = "rust1", since = "1.0.0")]
 impl<'a, T, const N: usize> IntoIterator for &'a [T; N] {
     type Item = &'a T;