core: merge IteratorPairExt into IteratorExt

This commit is contained in:
Jorge Aparicio 2015-01-03 08:19:51 -05:00
parent 6002c13f9b
commit 7095dd0070
3 changed files with 7 additions and 12 deletions

View File

@ -737,20 +737,15 @@ pub trait IteratorExt: Iterator + Sized {
fn rev(self) -> Rev<Self> {
Rev{iter: self}
}
}
#[unstable = "trait is unstable"]
impl<I> IteratorExt for I where I: Iterator {}
/// Extention trait for iterators of pairs.
#[unstable = "newly added trait, likely to be merged with IteratorExt"]
pub trait IteratorPairExt<A, B>: Iterator<Item=(A, B)> + Sized {
/// Converts an iterator of pairs into a pair of containers.
///
/// Loops through the entire iterator, collecting the first component of
/// each item into one new container, and the second component into another.
fn unzip<FromA, FromB>(mut self) -> (FromA, FromB) where
FromA: Default + Extend<A>, FromB: Default + Extend<B>
fn unzip<A, B, FromA, FromB>(mut self) -> (FromA, FromB) where
FromA: Default + Extend<A>,
FromB: Default + Extend<B>,
Self: Iterator<Item=(A, B)>,
{
struct SizeHint<A>(uint, Option<uint>);
impl<A> Iterator for SizeHint<A> {
@ -778,7 +773,8 @@ pub trait IteratorPairExt<A, B>: Iterator<Item=(A, B)> + Sized {
}
}
impl<A, B, I> IteratorPairExt<A, B> for I where I: Iterator<Item=(A, B)> {}
#[unstable = "trait is unstable"]
impl<I> IteratorExt for I where I: Iterator {}
/// A range iterator able to yield elements from both ends
///

View File

@ -44,7 +44,7 @@ pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
pub use iter::{Extend, IteratorExt};
pub use iter::{Iterator, DoubleEndedIterator};
pub use iter::{IteratorCloneExt, CloneIteratorExt};
pub use iter::{IteratorOrdExt, ExactSizeIterator, IteratorPairExt};
pub use iter::{IteratorOrdExt, ExactSizeIterator};
pub use option::Option::{mod, Some, None};
pub use ptr::{PtrExt, MutPtrExt};
pub use result::Result::{mod, Ok, Err};

View File

@ -30,7 +30,6 @@
#[stable] #[doc(no_inline)] pub use iter::ExactSizeIterator;
#[stable] #[doc(no_inline)] pub use iter::{Iterator, IteratorExt, Extend};
#[stable] #[doc(no_inline)] pub use iter::{IteratorCloneExt, IteratorOrdExt};
#[stable] #[doc(no_inline)] pub use iter::IteratorPairExt;
#[stable] #[doc(no_inline)] pub use option::Option::{mod, Some, None};
#[stable] #[doc(no_inline)] pub use ptr::{PtrExt, MutPtrExt};
#[stable] #[doc(no_inline)] pub use result::Result::{mod, Ok, Err};