diff options
| author | Jorge Aparicio <japaricious@gmail.com> | 2015-02-13 17:55:10 -0500 |
|---|---|---|
| committer | Jorge Aparicio <japaricious@gmail.com> | 2015-02-13 19:02:02 -0500 |
| commit | e7273784c7a80d8099e495015753d70e63e6d432 (patch) | |
| tree | 6e96958f2a8eaa48e8ac3e42781ab941e5c02dfc /src/libcore/array.rs | |
| parent | cf636c233dfeef5abf0de8fb35e23c0a161810d2 (diff) | |
| download | rust-e7273784c7a80d8099e495015753d70e63e6d432.tar.gz rust-e7273784c7a80d8099e495015753d70e63e6d432.zip | |
add an associated `Item` type to `IntoIterator`
Diffstat (limited to 'src/libcore/array.rs')
| -rw-r--r-- | src/libcore/array.rs | 24 |
1 files changed, 24 insertions, 0 deletions
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> { |
