mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-05-23 11:40:40 +00:00
104 lines
18 KiB
HTML
104 lines
18 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `itertools` crate."><meta name="keywords" content="rust, rustlang, rust-lang, itertools"><title>itertools - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="../favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../itertools/index.html'><img src='../rust-logo.png' alt='logo' width='100'></a><p class='location'>Crate itertools</p><div class="sidebar-elems"><a id='all-types' href='all.html'><p>See all itertools's items</p></a><div class="block items"><ul><li><a href="#reexports">Re-exports</a></li><li><a href="#modules">Modules</a></li><li><a href="#macros">Macros</a></li><li><a href="#enums">Enums</a></li><li><a href="#traits">Traits</a></li><li><a href="#functions">Functions</a></li></ul></div><p class='location'></p><script>window.sidebarCurrent = {name: 'itertools', ty: 'mod', relpath: '../'};</script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../src/itertools/lib.rs.html#1-2176' title='goto source code'>[src]</a></span><span class='in-band'>Crate <a class="mod" href=''>itertools</a></span></h1><div class='docblock'><p>Extra iterator adaptors, functions and macros.</p>
|
||
<p>To extend <a href="https://doc.rust-lang.org/std/iter/trait.Iterator.html"><code>Iterator</code></a> with methods in this crate, import
|
||
the <a href="./trait.Itertools.html"><code>Itertools</code> trait</a>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;</pre></div>
|
||
<p>Now, new methods like <a href="./trait.Itertools.html#method.interleave"><code>interleave</code></a>
|
||
are available on all iterators:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
|
||
|
||
<span class="kw">let</span> <span class="ident">it</span> <span class="op">=</span> (<span class="number">1</span>..<span class="number">3</span>).<span class="ident">interleave</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="op">-</span><span class="number">1</span>, <span class="op">-</span><span class="number">2</span>]);
|
||
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">it</span>, <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="op">-</span><span class="number">1</span>, <span class="number">2</span>, <span class="op">-</span><span class="number">2</span>]);</pre></div>
|
||
<p>Most iterator methods are also provided as functions (with the benefit
|
||
that they convert parameters using [<code>IntoIterator</code>]):</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">interleave</span>;
|
||
|
||
<span class="kw">for</span> <span class="ident">elt</span> <span class="kw">in</span> <span class="ident">interleave</span>(<span class="kw-2">&</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>], <span class="kw-2">&</span>[<span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>]) {
|
||
<span class="comment">/* loop body */</span>
|
||
}</pre></div>
|
||
<h2 id="crate-features" class="section-header"><a href="#crate-features">Crate Features</a></h2>
|
||
<ul>
|
||
<li><code>use_std</code>
|
||
<ul>
|
||
<li>Enabled by default.</li>
|
||
<li>Disable to compile itertools using <code>#![no_std]</code>. This disables
|
||
any items that depend on collections (like <code>group_by</code>, <code>unique</code>,
|
||
<code>kmerge</code>, <code>join</code> and many more).</li>
|
||
</ul>
|
||
</li>
|
||
</ul>
|
||
<h2 id="rust-version" class="section-header"><a href="#rust-version">Rust Version</a></h2>
|
||
<p>This version of itertools requires Rust 1.24 or later.</p>
|
||
</div><h2 id='reexports' class='section-header'><a href="#reexports">Re-exports</a></h2>
|
||
<table><tr><td><code>pub use <a class="mod" href="../itertools/structs/index.html" title="mod itertools::structs">structs</a>::*;</code></td></tr></table><h2 id='modules' class='section-header'><a href="#modules">Modules</a></h2>
|
||
<table><tr class='module-item'><td><a class="mod" href="structs/index.html" title='itertools::structs mod'>structs</a></td><td class='docblock-short'><p>The concrete iterator types.</p>
|
||
</td></tr></table><h2 id='macros' class='section-header'><a href="#macros">Macros</a></h2>
|
||
<table><tr class='module-item'><td><a class="macro" href="macro.iproduct.html" title='itertools::iproduct macro'>iproduct</a></td><td class='docblock-short'><p>Create an iterator over the “cartesian product” of iterators.</p>
|
||
</td></tr><tr class='module-item'><td><a class="macro" href="macro.izip.html" title='itertools::izip macro'>izip</a></td><td class='docblock-short'><p>Create an iterator running multiple iterators in lockstep.</p>
|
||
</td></tr></table><h2 id='enums' class='section-header'><a href="#enums">Enums</a></h2>
|
||
<table><tr class='module-item'><td><a class="enum" href="enum.Diff.html" title='itertools::Diff enum'>Diff</a></td><td class='docblock-short'><p>A type returned by the <a href="./fn.diff_with.html"><code>diff_with</code></a> function.</p>
|
||
</td></tr><tr class='module-item'><td><a class="enum" href="enum.Either.html" title='itertools::Either enum'>Either</a></td><td class='docblock-short'><p>The enum <code>Either</code> with variants <code>Left</code> and <code>Right</code> is a general purpose
|
||
sum type with two cases.</p>
|
||
</td></tr><tr class='module-item'><td><a class="enum" href="enum.EitherOrBoth.html" title='itertools::EitherOrBoth enum'>EitherOrBoth</a></td><td class='docblock-short'><p>Value that either holds a single A or B, or both.</p>
|
||
</td></tr><tr class='module-item'><td><a class="enum" href="enum.FoldWhile.html" title='itertools::FoldWhile enum'>FoldWhile</a></td><td class='docblock-short'><p>An enum used for controlling the execution of <code>.fold_while()</code>.</p>
|
||
</td></tr><tr class='module-item'><td><a class="enum" href="enum.MinMaxResult.html" title='itertools::MinMaxResult enum'>MinMaxResult</a></td><td class='docblock-short'><p><code>MinMaxResult</code> is an enum returned by <code>minmax</code>. See <code>Itertools::minmax()</code> for
|
||
more detail.</p>
|
||
</td></tr><tr class='module-item'><td><a class="enum" href="enum.Position.html" title='itertools::Position enum'>Position</a></td><td class='docblock-short'><p>A value yielded by <code>WithPosition</code>.
|
||
Indicates the position of this element in the iterator results.</p>
|
||
</td></tr></table><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2>
|
||
<table><tr class='module-item'><td><a class="trait" href="trait.Itertools.html" title='itertools::Itertools trait'>Itertools</a></td><td class='docblock-short'><p>An <a href="https://doc.rust-lang.org/std/iter/trait.Iterator.html"><code>Iterator</code></a> blanket implementation that provides extra adaptors and
|
||
methods.</p>
|
||
</td></tr><tr class='module-item'><td><a class="trait" href="trait.PeekingNext.html" title='itertools::PeekingNext trait'>PeekingNext</a></td><td class='docblock-short'><p>An iterator that allows peeking at an element before deciding to accept it.</p>
|
||
</td></tr></table><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
|
||
<table><tr class='module-item'><td><a class="fn" href="fn.all.html" title='itertools::all fn'>all</a></td><td class='docblock-short'><p>Test whether the predicate holds for all elements in the iterable.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.any.html" title='itertools::any fn'>any</a></td><td class='docblock-short'><p>Test whether the predicate holds for any elements in the iterable.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.assert_equal.html" title='itertools::assert_equal fn'>assert_equal</a></td><td class='docblock-short'><p>Assert that two iterables produce equal sequences, with the same
|
||
semantics as <em>equal(a, b)</em>.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.chain.html" title='itertools::chain fn'>chain</a></td><td class='docblock-short'><p>Create an iterator that first iterates <code>i</code> and then <code>j</code>.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.cloned.html" title='itertools::cloned fn'>cloned</a></td><td class='docblock-short'><p>Create an iterator that clones each element from &T to T</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.concat.html" title='itertools::concat fn'>concat</a></td><td class='docblock-short'><p>Combine all an iterator's elements into one element by using <code>Extend</code>.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.cons_tuples.html" title='itertools::cons_tuples fn'>cons_tuples</a></td><td class='docblock-short'><p>Create an iterator that maps for example iterators of
|
||
<code>((A, B), C)</code> to <code>(A, B, C)</code>.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.diff_with.html" title='itertools::diff_with fn'>diff_with</a></td><td class='docblock-short'><p>Compares every element yielded by both <code>i</code> and <code>j</code> with the given function in lock-step and
|
||
returns a <code>Diff</code> which describes how <code>j</code> differs from <code>i</code>.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.enumerate.html" title='itertools::enumerate fn'>enumerate</a></td><td class='docblock-short'><p>Iterate <code>iterable</code> with a running index.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.equal.html" title='itertools::equal fn'>equal</a></td><td class='docblock-short'><p>Return <code>true</code> if both iterables produce equal sequences
|
||
(elements pairwise equal and sequences of the same length),
|
||
<code>false</code> otherwise.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.fold.html" title='itertools::fold fn'>fold</a></td><td class='docblock-short'><p>Perform a fold operation over the iterable.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.interleave.html" title='itertools::interleave fn'>interleave</a></td><td class='docblock-short'><p>Create an iterator that interleaves elements in <code>i</code> and <code>j</code>.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.iterate.html" title='itertools::iterate fn'>iterate</a></td><td class='docblock-short'><p>Creates a new iterator that infinitely applies function to value and yields results.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.join.html" title='itertools::join fn'>join</a></td><td class='docblock-short'><p>Combine all iterator elements into one String, seperated by <code>sep</code>.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.kmerge.html" title='itertools::kmerge fn'>kmerge</a></td><td class='docblock-short'><p>Create an iterator that merges elements of the contained iterators using
|
||
the ordering function.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.kmerge_by.html" title='itertools::kmerge_by fn'>kmerge_by</a></td><td class='docblock-short'><p>Create an iterator that merges elements of the contained iterators.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.max.html" title='itertools::max fn'>max</a></td><td class='docblock-short'><p>Return the maximum value of the iterable.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.merge.html" title='itertools::merge fn'>merge</a></td><td class='docblock-short'><p>Create an iterator that merges elements in <code>i</code> and <code>j</code>.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.merge_join_by.html" title='itertools::merge_join_by fn'>merge_join_by</a></td><td class='docblock-short'><p>Return an iterator adaptor that merge-joins items from the two base iterators in ascending order.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.min.html" title='itertools::min fn'>min</a></td><td class='docblock-short'><p>Return the minimum value of the iterable.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.multipeek.html" title='itertools::multipeek fn'>multipeek</a></td><td class='docblock-short'><p>An iterator adaptor that allows the user to peek at multiple <code>.next()</code>
|
||
values without advancing the base iterator.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.multizip.html" title='itertools::multizip fn'>multizip</a></td><td class='docblock-short'><p>An iterator that generalizes <em>.zip()</em> and allows running multiple iterators in lockstep.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.partition.html" title='itertools::partition fn'>partition</a></td><td class='docblock-short'><p>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>.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.process_results.html" title='itertools::process_results fn'>process_results</a></td><td class='docblock-short'><p>“Lift” a function of the values of an iterator so that it can process
|
||
an iterator of <code>Result</code> values instead.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.put_back.html" title='itertools::put_back fn'>put_back</a></td><td class='docblock-short'><p>Create an iterator where you can put back a single item</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.put_back_n.html" title='itertools::put_back_n fn'>put_back_n</a></td><td class='docblock-short'><p>Create an iterator where you can put back multiple values to the front
|
||
of the iteration.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.rciter.html" title='itertools::rciter fn'>rciter</a></td><td class='docblock-short'><p>Return an iterator inside a <code>Rc<RefCell<_>></code> wrapper.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.repeat_call.html" title='itertools::repeat_call fn'>repeat_call</a></td><td class='docblock-short'><span class="stab deprecated">Deprecated</span><p>An iterator source that produces elements indefinitely by calling
|
||
a given closure.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.repeat_n.html" title='itertools::repeat_n fn'>repeat_n</a></td><td class='docblock-short'><p>Create an iterator that produces <code>n</code> repetitions of <code>element</code>.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.rev.html" title='itertools::rev fn'>rev</a></td><td class='docblock-short'><p>Iterate <code>iterable</code> in reverse.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.sorted.html" title='itertools::sorted fn'>sorted</a></td><td class='docblock-short'><p>Sort all iterator elements into a new iterator in ascending order.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.unfold.html" title='itertools::unfold fn'>unfold</a></td><td class='docblock-short'><p>Creates a new unfold source with the specified closure as the "iterator
|
||
function" and an initial state to eventually pass to the closure</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.zip.html" title='itertools::zip fn'>zip</a></td><td class='docblock-short'><p>Iterate <code>i</code> and <code>j</code> in lock step.</p>
|
||
</td></tr><tr class='module-item'><td><a class="fn" href="fn.zip_eq.html" title='itertools::zip_eq fn'>zip_eq</a></td><td class='docblock-short'><p>Iterate <code>i</code> and <code>j</code> in lock step.</p>
|
||
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>⏎</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g., <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g., <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../";window.currentCrate = "itertools";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html> |