From e7273784c7a80d8099e495015753d70e63e6d432 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Fri, 13 Feb 2015 17:55:10 -0500 Subject: add an associated `Item` type to `IntoIterator` --- src/libcore/array.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/libcore/array.rs') diff --git a/src/libcore/array.rs b/src/libcore/array.rs index a596fe4a588..abaa7594d04 100644 --- a/src/libcore/array.rs +++ b/src/libcore/array.rs @@ -48,6 +48,8 @@ macro_rules! array_impls { } } + // NOTE(stage0): remove impl after a snapshot + #[cfg(stage0)] impl<'a, T> IntoIterator for &'a [T; $N] { type IntoIter = Iter<'a, T>; @@ -56,7 +58,29 @@ macro_rules! array_impls { } } + #[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot + impl<'a, T> IntoIterator for &'a [T; $N] { + type Item = &'a T; + type IntoIter = Iter<'a, T>; + + fn into_iter(self) -> Iter<'a, T> { + self.iter() + } + } + + // NOTE(stage0): remove impl after a snapshot + #[cfg(stage0)] + impl<'a, T> IntoIterator for &'a mut [T; $N] { + type IntoIter = IterMut<'a, T>; + + fn into_iter(self) -> IterMut<'a, T> { + self.iter_mut() + } + } + + #[cfg(not(stage0))] // NOTE(stage0): remove cfg after a snapshot impl<'a, T> IntoIterator for &'a mut [T; $N] { + type Item = &'a mut T; type IntoIter = IterMut<'a, T>; fn into_iter(self) -> IterMut<'a, T> { -- cgit 1.4.1-3-g733a5