Crate itertools [] [src]

Itertools — extra iterator adaptors, functions and macros.

To use the iterator methods in this crate, import the Itertools trait:

use itertools::Itertools;

Some iterators or adaptors are used directly like regular structs, for example PutBack, Unfold, Zip, Stride

To enable the macros in this crate, use the #[macro_use] attribute:

#[macro_use] extern crate itertools;

License

Dual-licensed to be compatible with the Rust project.

Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0 or the MIT license http://opensource.org/licenses/MIT, at your option. This file may not be copied, modified, or distributed except according to those terms.

Reexports

pub use free::{enumerate, rev};

Modules

free

Free functions that create iterator adaptors or call iterator methods.

misc

A module of helper traits and iterators that are not intended to be used directly.

size_hint

Arithmetic on Iterator .size_hint() values.

Macros

iproduct!

Create an iterator over the “cartesian product” of iterators.

izip!

Create an iterator running multiple iterators in lockstep.

Structs

Batching

A “meta iterator adaptor”. Its closure recives a reference to the iterator and may pick off as many elements as it likes, to produce the next iterator element.

Chunk

An iterator for the elements in a single chunk.

Chunks

An iterator that yields the Chunk iterators.

ChunksLazy

ChunkLazy is the storage for a lazy chunking operation.

Coalesce

An iterator adaptor that may join together adjacent elements.

Combinations

An iterator to iterate through all the combinations of pairs in a Clone-able iterator.

CombinationsN

An iterator to iterate through all the n-length combinations in an iterator.

Dedup

An iterator adaptor that removes repeated duplicates.

Flatten

An iterator adapter to simply flatten a structure.

Format

Format all iterator elements lazily, separated by sep.

Group

An iterator for the elements in a single group.

GroupBy

An iterator adaptor that groups iterator elements. Consecutive elements that map to the same key (“runs”), are returned as the iterator elements.

GroupByLazy

GroupByLazy is the storage for the lazy grouping operation.

Groups

An iterator that yields the Group iterators.

ISlice

An iterator adaptor that yields a subset (a slice) of the base iterator.

Interleave

An iterator adaptor that alternates elements from two iterators until both run out.

InterleaveShortest

An iterator adaptor that alternates elements from the two iterators until one of them runs out.

Intersperse

An iterator adaptor to insert a particular value between each element of the adapted iterator.

KMerge

An iterator adaptor that merges an abitrary number of base iterators in ascending order. If all base iterators are sorted (ascending), the result is sorted.

Linspace

An iterator of a sequence of evenly spaced floats.

MendSlices

An iterator adaptor that glues together adjacent contiguous slices.

Merge

An iterator adaptor that merges the two base iterators in ascending order. If both base iterators are sorted (ascending), the result is sorted.

MergeBy

An iterator adaptor that merges the two base iterators in ascending order. If both base iterators are sorted (ascending), the result is sorted.

MultiPeek

An iterator adaptor that allows the user to peek at multiple .next() values without advancing itself.

PadUsing

An iterator adaptor that pads a sequence to a minimum length by filling missing elements using a closure.

Product

An iterator adaptor that iterates over the cartesian product of the element sets of two iterators I and J.

PutBack

An iterator adaptor that allows putting back a single item to the front of the iterator.

PutBackN

An iterator adaptor that allows putting multiple items in front of the iterator.

RcIter

A wrapper for Rc<RefCell<I>>, that implements the Iterator trait.

RepeatCall

An iterator source that produces elements indefinitely by calling a given closure.

RepeatN

An iterator that repeats an element exactly n times.

Step

An iterator adaptor that steps a number elements in the base iterator for each iteration.

Stride

An iterator similar to the slice iterator, but with a certain number of steps (the stride) skipped per iteration.

StrideMut

The mutable equivalent of Stride.

TakeWhileRef

An iterator adaptor that borrows from a Clone-able iterator to only pick off elements while the predicate returns true.

Tee

One half of an iterator pair where both return the same elements.

Unfold

Unfold is a general iterator builder: it has a mutable state value, and a closure with access to the state that produces the next value.

Unique

An iterator adapter to filter out duplicate elements.

UniqueBy

An iterator adapter to filter out duplicate elements.

WhileSome

An iterator adaptor that filters Option<A> iterator elements and produces A. Stops on the first None encountered.

Zip

An iterator that generalizes .zip() and allows running multiple iterators in lockstep.

ZipLongest

An iterator which iterates two other iterators simultaneously

ZipSlices

An iterator which iterates two slices simultaneously.

Enums

Diff

A type returned by the diff_with function.

EitherOrBoth

A value yielded by ZipLongest. Contains one or two values, depending on which of the input iterators are exhausted.

Traits

Itertools

The trait Itertools: extra iterator adaptors and methods for iterators.

Functions

assert_equal

Assert that two iterators produce equal sequences, with the same semantics as equal(a, b).

diff_with

Compares every element yielded by both i and j with the given function in lock-step and returns a Diff which describes how j differs from i.

equal

Return true if both iterators produce equal sequences (elements pairwise equal and sequences of the same length), false otherwise.

linspace

Return an iterator of evenly spaced floats.

partition

Partition a sequence using predicate pred so that elements that map to true are placed before elements which map to false.

Type Definitions

MapFn

The function pointer map iterator created with .map_fn().