<main><divclass="width-limiter"><navclass="sub"><formclass="search-form"><span></span><divid="sidebar-button"tabindex="-1"><ahref="../itertools/all.html"title="show sidebar"></a></div><inputclass="search-input"name="search"aria-label="Run search in the documentation"autocomplete="off"spellcheck="false"placeholder="Click or press ‘S’ to search, ‘?’ for more options…"type="search"><divid="help-button"tabindex="-1"><ahref="../help.html"title="help">?</a></div><divid="settings-menu"tabindex="-1"><ahref="../settings.html"title="settings"><imgwidth="22"height="22"alt="Change settings"src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><sectionid="main-content"class="content"><divclass="main-heading"><h1>Crate <aclass="mod"href="#">itertools</a><buttonid="copy-path"title="Copy item path to clipboard"><imgsrc="../static.files/clipboard-7571035ce49a181d.svg"width="19"height="18"alt="Copy item path"></button></h1><spanclass="out-of-band"><aclass="src"href="../src/itertools/lib.rs.html#1-4100">source</a> · <buttonid="toggle-all-docs"title="collapse all docs">[<span>−</span>]</button></span></div><detailsclass="toggle top-doc"open><summaryclass="hideme"><span>Expand description</span></summary><divclass="docblock"><p>Extra iterator adaptors, functions and macros.</p>
<p>To extend <ahref="https://doc.rust-lang.org/1.78.0/core/iter/traits/iterator/trait.Iterator.html"title="trait core::iter::traits::iterator::Iterator"><code>Iterator</code></a> with methods in this crate, import
that they convert parameters using <ahref="https://doc.rust-lang.org/1.78.0/core/iter/traits/collect/trait.IntoIterator.html"title="trait core::iter::traits::collect::IntoIterator"><code>IntoIterator</code></a>):</p>
</div></details><h2id="reexports"class="section-header">Re-exports<ahref="#reexports"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><code>pub use crate::<aclass="mod"href="structs/index.html"title="mod itertools::structs">structs</a>::*;</code></div></li></ul><h2id="modules"class="section-header">Modules<ahref="#modules"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="mod"href="structs/index.html"title="mod itertools::structs">structs</a></div><divclass="desc docblock-short">The concrete iterator types.</div></li><li><divclass="item-name"><aclass="mod"href="traits/index.html"title="mod itertools::traits">traits</a></div><divclass="desc docblock-short">Traits helpful for using certain <code>Itertools</code> methods in generic contexts.</div></li></ul><h2id="macros"class="section-header">Macros<ahref="#macros"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="macro"href="macro.chain.html"title="macro itertools::chain">chain</a></div><divclass="desc docblock-short"><ahref="https://doc.rust-lang.org/1.78.0/core/iter/traits/iterator/trait.Iterator.html#method.chain"title="method core::iter::traits::iterator::Iterator::chain">Chain</a> zero or more iterators together into one sequence.</div></li><li><divclass="item-name"><aclass="macro"href="macro.iproduct.html"title="macro itertools::iproduct">iproduct</a></div><divclass="desc docblock-short">Create an iterator over the “cartesian product” of iterators.</div></li><li><divclass="item-name"><aclass="macro"href="macro.izip.html"title="macro itertools::izip">izip</a></div><divclass="desc docblock-short">Create an iterator running multiple iterators in lockstep.</div></li></ul><h2id="enums"class="section-header">Enums<ahref="#enums"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="enum"href="enum.Diff.html"title="enum itertools::Diff">Diff</a></div><divclass="desc docblock-short">A type returned by the <ahref="fn.diff_with.html"title="fn itertools::diff_with"><code>diff_with</code></a> function.</div></li><li><divclass="item-name"><aclass="enum"href="enum.Either.html"title="enum itertools::Either">Either</a></div><divclass="desc docblock-short">The enum <code>Either</code> with variants <code>Left</code> and <code>Right</code> is a general purpose
sum type with two cases.</div></li><li><divclass="item-name"><aclass="enum"href="enum.EitherOrBoth.html"title="enum itertools::EitherOrBoth">EitherOrBoth</a></div><divclass="desc docblock-short">Value that either holds a single A or B, or both.</div></li><li><divclass="item-name"><aclass="enum"href="enum.FoldWhile.html"title="enum itertools::FoldWhile">FoldWhile</a></div><divclass="desc docblock-short">An enum used for controlling the execution of <code>fold_while</code>.</div></li><li><divclass="item-name"><aclass="enum"href="enum.MinMaxResult.html"title="enum itertools::MinMaxResult">MinMaxResult</a></div><divclass="desc docblock-short"><code>MinMaxResult</code> is an enum returned by <code>minmax</code>.</div></li><li><divclass="item-name"><aclass="enum"href="enum.Position.html"title="enum itertools::Position">Position</a></div><divclass="desc docblock-short">The first component of the value yielded by <code>WithPosition</code>.
Indicates the position of this element in the iterator results.</div></li></ul><h2id="traits"class="section-header">Traits<ahref="#traits"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="trait"href="trait.Itertools.html"title="trait itertools::Itertools">Itertools</a></div><divclass="desc docblock-short">An <ahref="https://doc.rust-lang.org/1.78.0/core/iter/traits/iterator/trait.Iterator.html"title="trait core::iter::traits::iterator::Iterator"><code>Iterator</code></a> blanket implementation that provides extra adaptors and
methods.</div></li><li><divclass="item-name"><aclass="trait"href="trait.MultiUnzip.html"title="trait itertools::MultiUnzip">MultiUnzip</a></div><divclass="desc docblock-short">An iterator that can be unzipped into multiple collections.</div></li><li><divclass="item-name"><aclass="trait"href="trait.PeekingNext.html"title="trait itertools::PeekingNext">PeekingNext</a></div><divclass="desc docblock-short">An iterator that allows peeking at an element before deciding to accept it.</div></li></ul><h2id="functions"class="section-header">Functions<ahref="#functions"class="anchor">§</a></h2><ulclass="item-table"><li><divclass="item-name"><aclass="fn"href="fn.all.html"title="fn itertools::all">all</a></div><divclass="desc docblock-short">Test whether the predicate holds for all elements in the iterable.</div></li><li><divclass="item-name"><aclass="fn"href="fn.any.html"title="fn itertools::any">any</a></div><divclass="desc docblock-short">Test whether the predicate holds for any elements in the iterable.</div></li><li><divclass="item-name"><aclass="fn"href="fn.assert_equal.html"title="fn itertools::assert_equal">assert_equal</a></div><divclass="desc docblock-short">Assert that two iterables produce equal sequences, with the same
semantics as <ahref="fn.equal.html"title="fn itertools::equal"><code>equal(a, b)</code></a>.</div></li><li><divclass="item-name"><aclass="fn"href="fn.chain.html"title="fn itertools::chain">chain</a></div><divclass="desc docblock-short">Takes two iterables and creates a new iterator over both in sequence.</div></li><li><divclass="item-name"><aclass="fn"href="fn.cloned.html"title="fn itertools::cloned">cloned</a></div><divclass="desc docblock-short">Create an iterator that clones each element from &T to T</div></li><li><divclass="item-name"><aclass="fn"href="fn.concat.html"title="fn itertools::concat">concat</a></div><divclass="desc docblock-short">Combine all an iterator’s elements into one element by using <ahref="https://doc.rust-lang.org/1.78.0/core/iter/traits/collect/trait.Extend.html"title="trait core::iter::traits::collect::Extend"><code>Extend</code></a>.</div></li><li><divclass="item-name"><aclass="fn"href="fn.cons_tuples.html"title="fn itertools::cons_tuples">cons_tuples</a></div><divclass="desc docblock-short">Create an iterator that maps for example iterators of
<code>((A, B), C)</code> to <code>(A, B, C)</code>.</div></li><li><divclass="item-name"><aclass="fn"href="fn.diff_with.html"title="fn itertools::diff_with">diff_with</a></div><divclass="desc docblock-short">Compares every element yielded by both <code>i</code> and <code>j</code> with the given function in lock-step and
returns a <ahref="enum.Diff.html"title="enum itertools::Diff"><code>Diff</code></a> which describes how <code>j</code> differs from <code>i</code>.</div></li><li><divclass="item-name"><aclass="fn"href="fn.enumerate.html"title="fn itertools::enumerate">enumerate</a></div><divclass="desc docblock-short">Iterate <code>iterable</code> with a running index.</div></li><li><divclass="item-name"><aclass="fn"href="fn.equal.html"title="fn itertools::equal">equal</a></div><divclass="desc docblock-short">Return <code>true</code> if both iterables produce equal sequences
(elements pairwise equal and sequences of the same length),
<code>false</code> otherwise.</div></li><li><divclass="item-name"><aclass="fn"href="fn.fold.html"title="fn itertools::fold">fold</a></div><divclass="desc docblock-short">Perform a fold operation over the iterable.</div></li><li><divclass="item-name"><aclass="fn"href="fn.interleave.html"title="fn itertools::interleave">interleave</a></div><divclass="desc docblock-short">Create an iterator that interleaves elements in <code>i</code> and <code>j</code>.</div></li><li><divclass="item-name"><aclass="fn"href="fn.intersperse.html"title="fn itertools::intersperse">intersperse</a></div><divclass="desc docblock-short">Iterate <code>iterable</code> with a particular value inserted between each element.</div></li><li><divclass="item-name"><aclass="fn"href="fn.intersperse_with.html"title="fn itertools::intersperse_with">intersperse_with</a></div><divclass="desc docblock-short">Iterate <code>iterable</code> with a particular value created by a function inserted
between each element.</div></li><li><divclass="item-name"><aclass="fn"href="fn.iterate.html"title="fn itertools::iterate">iterate</a></div><divclass="desc docblock-short">Creates a new iterator that infinitely applies function to value and yields results.</div></li><li><divclass="item-name"><aclass="fn"href="fn.join.html"title="fn itertools::join">join</a></div><divclass="desc docblock-short">Combine all iterator elements into one String, separated by <code>sep</code>.</div></li><li><divclass="item-name"><aclass="fn"href="fn.kmerge.html"title="fn itertools::kmerge">kmerge</a></div><divclass="desc docblock-short">Create an iterator that merges elements of the contained iterators using
the ordering function.</div></li><li><divclass="item-name"><aclass="fn"href="fn.kmerge_by.html"title="fn itertools::kmerge_by">kmerge_by</a></div><divclass="desc docblock-short">Create an iterator that merges elements of the contained iterators.</div></li><li><divclass="item-name"><aclass="fn"href="fn.max.html"title="fn itertools::max">max</a></div><divclass="desc docblock-short">Return the maximum value of the iterable.</div></li><li><divclass="item-name"><aclass="fn"href="fn.merge.html"title="fn itertools::merge">merge</a></div><divclass="desc docblock-short">Create an iterator that merges elements in <code>i</code> and <code>j</code>.</div></li><li><divclass="item-name"><aclass="fn"href="fn.merge_join_by.html"title="fn itertools::merge_join_by">merge_join_by</a></div><divclass="desc docblock-short">Return an iterator adaptor that merge-joins items from the two base iterators in ascending order.</div></li><li><divclass="item-name"><aclass="fn"href="fn.min.html"title="fn itertools::min">min</a></div><divclass="desc docblock-short">Return the minimum value of the iterable.</div></li><li><divclass="item-name"><aclass="fn"href="fn.multipeek.html"title="fn itertools::multipeek">multipeek</a></div><divclass="desc docblock-short">An iterator adaptor that allows the user to peek at multiple <code>.next()</code>
values without advancing the base iterator.</div></li><li><divclass="item-name"><aclass="fn"href="fn.multiunzip.html"title="fn itertools::multiunzip">multiunzip</a></div><divclass="desc docblock-short">Converts an iterator of tuples into a tuple of containers.</div></li><li><divclass="item-name"><aclass="fn"href="fn.multizip.html"title="fn itertools::multizip">multizip</a></div><divclass="desc docblock-short">An iterator that generalizes <em>.zip()</em> and allows running multiple iterators in lockstep.</div></li><li><divclass="item-name"><aclass="fn"href="fn.partition.html"title="fn itertools::partition">partition</a></div><divclass="desc docblock-short">Partition a sequence using predicate <code>pred</code> so that elements
that map to <code>true</code> are placed before elements which map to <code>false</code>.</div></li><li><divclass="item-name"><aclass="fn"href="fn.peek_nth.html"title="fn itertools::peek_nth">peek_nth</a></div><divclass="desc docblock-short">A drop-in replacement for <ahref="https://doc.rust-lang.org/1.78.0/core/iter/adapters/peekable/struct.Peekable.html"title="struct core::iter::adapters::peekable::Peekable"><code>std::iter::Peekable</code></a> which adds a <code>peek_nth</code>
method allowing the user to <code>peek</code> at a value several iterations forward
without advancing the base iterator.</div></li><li><divclass="item-name"><aclass="fn"href="fn.process_results.html"title="fn itertools::process_results">process_results</a></div><divclass="desc docblock-short">“Lift” a function of the values of an iterator so that it can process
an iterator of <code>Result</code> values instead.</div></li><li><divclass="item-name"><aclass="fn"href="fn.put_back.html"title="fn itertools::put_back">put_back</a></div><divclass="desc docblock-short">Create an iterator where you can put back a single item</div></li><li><divclass="item-name"><aclass="fn"href="fn.put_back_n.html"title="fn itertools::put_back_n">put_back_n</a></div><divclass="desc docblock-short">Create an iterator where you can put back multiple values to the front
of the iteration.</div></li><li><divclass="item-name"><aclass="fn"href="fn.rciter.html"title="fn itertools::rciter">rciter</a></div><divclass="desc docblock-short">Return an iterator inside a <code>Rc<RefCell<_>></code> wrapper.</div></li><li><divclass="item-name"><aclass="fn"href="fn.repeat_call.html"title="fn itertools::repeat_call">repeat_call</a><spanclass="stab deprecated"title="">Deprecated</span></div><divclass="desc docblock-short">An iterator source that produces elements indefinitely by calling
a given closure.</div></li><li><divclass="item-name"><aclass="fn"href="fn.repeat_n.html"title="fn itertools::repeat_n">repeat_n</a></div><divclass="desc docblock-short">Create an iterator that produces <code>n</code> repetitions of <code>element</code>.</div></li><li><divclass="item-name"><aclass="fn"href="fn.rev.html"title="fn itertools::rev">rev</a></div><divclass="desc docblock-short">Iterate <code>iterable</code> in reverse.</div></li><li><divclass="item-name"><aclass="fn"href="fn.sorted.html"title="fn itertools::sorted">sorted</a></div><divclass="desc docblock-short">Sort all iterator elements into a new iterator in ascending order.</div></li><li><divclass="item-name"><aclass="fn"href="fn.sorted_unstable.html"title="fn itertools::sorted_unstable">sorted_unstable</a></div><divclass="desc docblock-short">Sort all iterator elements into a new iterator in ascending order.
This sort is unstable (i.e., may reorder equal elements).
<ahref="https://doc.rust-lang.org/1.78.0/core/iter/traits/collect/trait.IntoIterator.html"title="trait core::iter::traits::collect::IntoIterator"><code>IntoIterator</code></a> enabled version of <ahref="trait.Itertools.html#method.sorted_unstable"title="method itertools::Itertools::sorted_unstable"><code>Itertools::sorted_unstable</code></a>.</div></li><li><divclass="item-name"><aclass="fn"href="fn.unfold.html"title="fn itertools::unfold">unfold</a></div><divclass="desc docblock-short">Creates a new unfold source with the specified closure as the “iterator
function” and an initial state to eventually pass to the closure</div></li><li><divclass="item-name"><aclass="fn"href="fn.zip.html"title="fn itertools::zip">zip</a><spanclass="stab deprecated"title="">Deprecated</span></div><divclass="desc docblock-short">Converts the arguments to iterators and zips them.</div></li><li><divclass="item-name"><aclass="fn"href="fn.zip_eq.html"title="fn itertools::zip_eq">zip_eq</a></div><divclass="desc docblock-short">Iterate <code>i</code> and <code>j</code> in lock step.</div></li></ul></section></div></main></body></html>