iterator: add a bit of documentation
This commit is contained in:
@@ -8,7 +8,14 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
//! Composable iterator objects
|
/*! Composable external iterators
|
||||||
|
|
||||||
|
The `Iterator` trait defines an interface for objects which implement iteration as a state machine.
|
||||||
|
|
||||||
|
Algorithms like `zip` are provided as `Iterator` implementations which wrap other objects
|
||||||
|
implementing the `Iterator` trait.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
use prelude::*;
|
use prelude::*;
|
||||||
|
|
||||||
@@ -17,6 +24,10 @@ pub trait Iterator<A> {
|
|||||||
fn next(&mut self) -> Option<A>;
|
fn next(&mut self) -> Option<A>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Iterator adaptors provided for every `Iterator` implementation. The adaptor objects are also
|
||||||
|
/// implementations of the `Iterator` trait.
|
||||||
|
///
|
||||||
|
/// In the future these will be default methods instead of a utility trait.
|
||||||
pub trait IteratorUtil<A> {
|
pub trait IteratorUtil<A> {
|
||||||
fn chain(self, other: Self) -> ChainIterator<Self>;
|
fn chain(self, other: Self) -> ChainIterator<Self>;
|
||||||
fn zip<B, U: Iterator<B>>(self, other: U) -> ZipIterator<Self, U>;
|
fn zip<B, U: Iterator<B>>(self, other: U) -> ZipIterator<Self, U>;
|
||||||
@@ -31,6 +42,10 @@ pub trait IteratorUtil<A> {
|
|||||||
fn advance(&mut self, f: &fn(A) -> bool);
|
fn advance(&mut self, f: &fn(A) -> bool);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Iterator adaptors provided for every `Iterator` implementation. The adaptor objects are also
|
||||||
|
/// implementations of the `Iterator` trait.
|
||||||
|
///
|
||||||
|
/// In the future these will be default methods instead of a utility trait.
|
||||||
impl<A, T: Iterator<A>> IteratorUtil<A> for T {
|
impl<A, T: Iterator<A>> IteratorUtil<A> for T {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn chain(self, other: T) -> ChainIterator<T> {
|
fn chain(self, other: T) -> ChainIterator<T> {
|
||||||
|
|||||||
Reference in New Issue
Block a user