core: add the IntoIterator trait
This commit is contained in:
@@ -18,12 +18,14 @@ use clone::Clone;
|
||||
use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
|
||||
use fmt;
|
||||
use hash::{Hash, Hasher, self};
|
||||
use iter::IntoIterator;
|
||||
use marker::Copy;
|
||||
#[cfg(stage0)]
|
||||
use ops::{Deref, FullRange};
|
||||
#[cfg(not(stage0))]
|
||||
use ops::Deref;
|
||||
use option::Option;
|
||||
use slice::{Iter, IterMut, SliceExt};
|
||||
|
||||
// macro for implementing n-ary tuple functions and operations
|
||||
macro_rules! array_impls {
|
||||
@@ -49,6 +51,22 @@ macro_rules! array_impls {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> IntoIterator for &'a [T; $N] {
|
||||
type Iter = Iter<'a, T>;
|
||||
|
||||
fn into_iter(self) -> Iter<'a, T> {
|
||||
self.iter()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> IntoIterator for &'a mut [T; $N] {
|
||||
type Iter = IterMut<'a, T>;
|
||||
|
||||
fn into_iter(self) -> IterMut<'a, T> {
|
||||
self.iter_mut()
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
impl<A, B> PartialEq<[B; $N]> for [A; $N] where A: PartialEq<B> {
|
||||
#[inline]
|
||||
|
||||
Reference in New Issue
Block a user