Skip to content

Commit

Permalink
core: merge IteratorPairExt into IteratorExt
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorge Aparicio committed Jan 3, 2015
1 parent 6002c13 commit 7095dd0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
16 changes: 6 additions & 10 deletions src/libcore/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down Expand Up @@ -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
///
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
1 change: 0 additions & 1 deletion src/libstd/prelude/v1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit 7095dd0

Please sign in to comment.