Module

core::iter

source

The iterator protocol and iterator adapters.

Types

RangeThe numbers from cur up to, not including, end.
Mapf applied to each item.
FilterThe items pred keeps.
PairA named pair: the item type of zip and enumerate.
ZipPairs the two iterators' items until either runs out.
EnumerateEach item with its index, counting from 0: Pair { a: index, b: item }.
TakeAt most left more items; the inner iterator is not pulled past them, nor again once it has run out (left drops to 0).
SkipThe items after the first left.
TakeWhileItems while pred keeps them; the first it rejects ends the iterator and is dropped (Copy[T]).
ChainThe first iterator's items, then the second's.

Traits

IteratorA source of items, produced one per call to next.

Functions

rangeThe numbers from start up to, not including, end.
foldLeft-folds f over every item, returning the exhausted iterator with the result.
mapEach item of it through f.
filterThe items of it that pred keeps.
filter_skipPulls from the inner iterator until pred keeps an item or it runs out.
zipThe items of a and b in pairs, until either runs out.

Instances

Iterator[Range -> usize]range: the next number, and None from end on, however often it is asked.
Iterator[Map[I, In, Out, Env] -> Out]map: the next item of the inner iterator, through f.
Iterator[Filter[I, In, Env] -> In]filter: the next item of the inner iterator that pred keeps.
Iterator[Zip[IA, IB] -> Pair[ItemA, ItemB]]zip: the next item of each, paired, until either runs out.
Iterator[Enumerate[I] -> Pair[usize, T]]enumerate: the next item with its index.
Iterator[Take[I] -> T]take: the next item while any of the count is left.
Iterator[Skip[I] -> T]skip: the items after the first left.
Iterator[TakeWhile[I, T, Env] -> T]take_while: the next item while pred holds of it.
Iterator[Chain[IA, IB] -> T]chain: the items of a, then those of b.

Function declarations

fn rangesource

fn range(start: usize, end: usize) -> Range { ... }

The numbers from start up to, not including, end.

fn foldsource

forall Self, Item, Acc, Env where Iterator[Self -> Item], Copy[Env].
fn fold(it: Self, acc: Acc, f: closure[Env](Acc, Item) -> Acc) -> (Self, Acc) { ... }

Left-folds f over every item, returning the exhausted iterator with the result. f captures freely; Copy[Env] lets the one closure be called for every item.

fn mapsource

forall I, In, Out, Env where Iterator[I -> In].
fn map(it: I, f: closure[Env](In) -> Out) -> Map[I, In, Out, Env] { ... }

Each item of it through f.

fn filtersource

forall I, In, Env where Iterator[I -> In], Copy[In].
fn filter(it: I, pred: closure[Env](In) -> bool) -> Filter[I, In, Env] { ... }

The items of it that pred keeps.

fn filter_skipsource

forall I, In, Env where Iterator[I -> In], Copy[In], Copy[Env].
fn filter_skip(&it: I, pred: closure[Env](In) -> bool) -> Option[In] { ... }

Pulls from the inner iterator until pred keeps an item or it runs out. A plain function rather than the instance's own body, so that it recurses on the inner I itself.

fn zipsource

forall IA, IB.
fn zip(a: IA, b: IB) -> Zip[IA, IB] { ... }

The items of a and b in pairs, until either runs out.

Instance declarations

instance Iterator[Range -> usize]source

instance Iterator[Range -> usize] { ... }

range: the next number, and None from end on, however often it is asked.

instance Iterator[Map[I, In, Out, Env] -> Out]source

forall I, In, Out, Env where Iterator[I -> In], Copy[Env].
instance Iterator[Map[I, In, Out, Env] -> Out] { ... }

map: the next item of the inner iterator, through f.

instance Iterator[Filter[I, In, Env] -> In]source

forall I, In, Env where Iterator[I -> In], Copy[In], Copy[Env].
instance Iterator[Filter[I, In, Env] -> In] { ... }

filter: the next item of the inner iterator that pred keeps.

instance Iterator[Zip[IA, IB] -> Pair[ItemA, ItemB]]source

forall IA, IB, ItemA, ItemB where Iterator[IA -> ItemA], Iterator[IB -> ItemB], Copy[ItemA], Copy[ItemB].
instance Iterator[Zip[IA, IB] -> Pair[ItemA, ItemB]] { ... }

zip: the next item of each, paired, until either runs out.

instance Iterator[Enumerate[I] -> Pair[usize, T]]source

forall I, T where Iterator[I -> T].
instance Iterator[Enumerate[I] -> Pair[usize, T]] { ... }

enumerate: the next item with its index.

instance Iterator[Take[I] -> T]source

forall I, T where Iterator[I -> T].
instance Iterator[Take[I] -> T] { ... }

take: the next item while any of the count is left.

instance Iterator[Skip[I] -> T]source

forall I, T where Iterator[I -> T], Copy[T].
instance Iterator[Skip[I] -> T] { ... }

skip: the items after the first left.

instance Iterator[TakeWhile[I, T, Env] -> T]source

forall I, T, Env where Iterator[I -> T], Copy[T], Copy[Env].
instance Iterator[TakeWhile[I, T, Env] -> T] { ... }

take_while: the next item while pred holds of it.

instance Iterator[Chain[IA, IB] -> T]source

forall IA, IB, T where Iterator[IA -> T], Iterator[IB -> T].
instance Iterator[Chain[IA, IB] -> T] { ... }

chain: the items of a, then those of b.

Blanket methods

method mapsource

forall Out, Env.
fn map(self, f: closure[Env](T) -> Out) -> Map[I, T, Out, Env] { ... }

In forall I, T where Iterator[I -> T].

Each item through f.

method filtersource

forall Env where Copy[T].
fn filter(self, pred: closure[Env](T) -> bool) -> Filter[I, T, Env] { ... }

In forall I, T where Iterator[I -> T].

The items pred keeps.

method zipsource

forall J.
fn zip(self, other: J) -> Zip[I, J] { ... }

In forall I, T where Iterator[I -> T].

This iterator's items paired with other's, until either runs out.

method foldsource

forall Acc, Env where Copy[Env].
fn fold(self, acc: Acc, f: closure[Env](Acc, T) -> Acc) -> (I, Acc) { ... }

In forall I, T where Iterator[I -> T].

Left-folds f over every item, returning the exhausted iterator with the result.

method enumeratesource

fn enumerate(self) -> Enumerate[I] { ... }

In forall I, T where Iterator[I -> T].

Each item with its index, counting from 0.

method takesource

fn take(self, count: usize) -> Take[I] { ... }

In forall I, T where Iterator[I -> T].

At most the first count items.

method chainsource

forall J.
fn chain(self, other: J) -> Chain[I, J] { ... }

In forall I, T where Iterator[I -> T].

This iterator's items, then other's.

method skipsource

fn skip(self, count: usize) -> Skip[I] { ... }

In forall I, T where Iterator[I -> T], Copy[T].

The items after the first count.

method take_whilesource

forall Env where Copy[Env].
fn take_while(self, pred: closure[Env](T) -> bool) -> TakeWhile[I, T, Env] { ... }

In forall I, T where Iterator[I -> T], Copy[T].

The items up to the first one pred rejects.

method countsource

fn count(self) -> (I, usize) { ... }

In forall I, T where Iterator[I -> T], Copy[T].

How many items are left, with the exhausted iterator.

method anysource

forall Env where Copy[Env].
fn any(self, pred: closure[Env](T) -> bool) -> (I, bool) { ... }

In forall I, T where Iterator[I -> T], Copy[T].

Whether pred holds for some item, with the iterator, read up to that item.

method allsource

forall Env where Copy[Env].
fn all(self, pred: closure[Env](T) -> bool) -> (I, bool) { ... }

In forall I, T where Iterator[I -> T], Copy[T].

Whether pred holds for every item, with the iterator, read up to the first item it fails for.

method findsource

forall Env where Copy[Env].
fn find(self, pred: closure[Env](T) -> bool) -> (I, Option[T]) { ... }

In forall I, T where Iterator[I -> T], Copy[T].

The first item pred holds for, with the iterator, read up to that item.