diff options
Diffstat (limited to 'src/libcore/slice.rs')
| -rw-r--r-- | src/libcore/slice.rs | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 40e66db3ae5..a368ddba9bc 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -41,7 +41,6 @@ use cmp::Ordering::{Less, Equal, Greater}; use cmp; use default::Default; use iter::*; -use marker::Copy; use num::Int; use ops::{FnMut, self, Index}; #[cfg(stage0)] @@ -637,6 +636,22 @@ impl<'a, T> Default for &'a [T] { // Iterators // +impl<'a, T> IntoIterator for &'a [T] { + type Iter = Iter<'a, T>; + + fn into_iter(self) -> Iter<'a, T> { + self.iter() + } +} + +impl<'a, T> IntoIterator for &'a mut [T] { + type Iter = IterMut<'a, T>; + + fn into_iter(self) -> IterMut<'a, T> { + self.iter_mut() + } +} + // The shared definition of the `Iter` and `IterMut` iterators macro_rules! iterator { (struct $name:ident -> $ptr:ty, $elem:ty) => { @@ -784,8 +799,6 @@ impl<'a, T> Iter<'a, T> { } } -impl<'a,T> Copy for Iter<'a,T> {} - iterator!{struct Iter -> *const T, &'a T} #[stable(feature = "rust1", since = "1.0.0")] @@ -793,7 +806,7 @@ impl<'a, T> ExactSizeIterator for Iter<'a, T> {} #[stable(feature = "rust1", since = "1.0.0")] impl<'a, T> Clone for Iter<'a, T> { - fn clone(&self) -> Iter<'a, T> { *self } + fn clone(&self) -> Iter<'a, T> { Iter { ptr: self.ptr, end: self.end, marker: self.marker } } } #[unstable(feature = "core", reason = "trait is experimental")] |
