Module grabbag::iter [] [src]

This module contains a set of iterator extensions. Rather than being named for the type of iterator they are implemented on, they are named for the method (or group of associated methods) being implemented.

If you can't be bothered to import them individually, you can just pull in iter::prelude::* instead.

Standard Features

The iterator extensions, where possible, should implement the following features:

  • Clone, which produces an independent version of the iterator.
  • DoubleEndedIterator.
  • ExactSizeIterator.
  • Show.
  • Accurate size_hint (depending on the transform being performed, and the accuracy of the underlying iterator).
  • An unwrap method, which returns any owned values passed into the iterator; typically, this is the original iterator.

Modules

accumulate
cartesian_product
clone_each
fold
group_by
intersperse
keep_some
pad_tail_to
prelude

This module just centralises all the iterator extension traits in one place, suitable for glob importing.

round_robin
skip_exactly
sorted
stride
take_exactly
tee
zip_longest

Traits

AccumulateIterator

( a0, a1, a2, ... ), ⊗  →  ( a0, (a0a1), ((a0a1) ⊗ a2), ... )

CartesianProductIterator

( a0, a1, ... ), ( b0, b1, ... )  →  ( (a0, b0), (a0, b1), ..., (a1, b0), (a1, b1), ... )

CloneEachIterator

( a0, a1, ... )  →  ( a0.clone(), a1.clone(), ... )

FoldlIterator

( a0, a1, a2, ... ),  →   →  ((a0) ⊗ a1) ⊗ a2) ⊗ ...

FoldrIterator

( ..., an-2, an-1, an, ), ⊗ → ... ⊗ (an-2 ⊗ (an-1 ⊗ (an)))

GroupByIterator

Sequence of iterators containing successive elements of the subject which have the same group according to a group function.

IntersperseIterator

(a0, a1, ..., an), i  →  (a0, i, a1, i, ..., i, an)

KeepSomeIterator

a  →  (e | e  →  a : Some(e))

PadTailToIterator

Pads a sequence to a minimum length.

RoundRobinIterator

(a0, a1, ...), (b0, b1, ...)  →  (a0, b0, a1, b1, ...)

SkipExactlyIterator

(..., ai-1, ai, ai+1, ...), i  →  (ai, ai+1, ...)

SortedIterator

Shorthand for collecting and sorting an iterator.

StrideIterator

a, n  →  (ai | ai  →  a : imod n )

TakeExactlyIterator

(a0, ..., ai-1, ai, ai+1, ...), i  →  (a0, ..., ai-1)

TeeIterator

a  →  a, a

ZipLongestIterator

(..., am), (..., bm, bm+1, ..., bn)  →  ( ..., (Some(am), Some(bm)), (None, Some(bm+1)), ..., (None, Some(bn)) )