mentat/itertools/trait.Itertools.html

1229 lines
319 KiB
HTML
Raw Normal View History

2018-08-22 17:04:13 +00:00
<!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` trait in crate `itertools`.">
<meta name="keywords" content="rust, rustlang, rust-lang, Itertools">
<title>itertools::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="../main.css" id="themeStyle">
<script src="../storage.js"></script>
</head>
<body class="rustdoc trait">
<!--[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">&#9776;</div>
<p class='location'>Trait Itertools</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#provided-methods">Provided Methods</a><div class="sidebar-links"><a href="#method.interleave">interleave</a><a href="#method.interleave_shortest">interleave_shortest</a><a href="#method.intersperse">intersperse</a><a href="#method.zip_longest">zip_longest</a><a href="#method.zip_eq">zip_eq</a><a href="#method.batching">batching</a><a href="#method.group_by">group_by</a><a href="#method.chunks">chunks</a><a href="#method.tuple_windows">tuple_windows</a><a href="#method.tuples">tuples</a><a href="#method.tee">tee</a><a href="#method.step">step</a><a href="#method.map_results">map_results</a><a href="#method.merge">merge</a><a href="#method.merge_by">merge_by</a><a href="#method.merge_join_by">merge_join_by</a><a href="#method.kmerge">kmerge</a><a href="#method.kmerge_by">kmerge_by</a><a href="#method.cartesian_product">cartesian_product</a><a href="#method.multi_cartesian_product">multi_cartesian_product</a><a href="#method.coalesce">coalesce</a><a href="#method.dedup">dedup</a><a href="#method.unique">unique</a><a href="#method.unique_by">unique_by</a><a href="#method.peeking_take_while">peeking_take_while</a><a href="#method.take_while_ref">take_while_ref</a><a href="#method.while_some">while_some</a><a href="#method.tuple_combinations">tuple_combinations</a><a href="#method.combinations">combinations</a><a href="#method.pad_using">pad_using</a><a href="#method.flatten">flatten</a><a href="#method.with_position">with_position</a><a href="#method.positions">positions</a><a href="#method.update">update</a><a href="#method.next_tuple">next_tuple</a><a href="#method.collect_tuple">collect_tuple</a><a href="#method.find_position">find_position</a><a href="#method.all_equal">all_equal</a><a href="#method.dropping">dropping</a><a href="#method.dropping_back">dropping_back</a><a href="#method.foreach">foreach</a><a href="#method.concat">concat</a><a href="#method.collect_vec">collect_vec</a><a href="#method.set_from">set_from</a><a href="#method.join">join</a><a href="#method.format">format</a><a href="#method.format_with">format_with</a><a href="#method.fold_results">fold_results</a><a href="#method.fold_options">fold_options</a><a href="#method.fold1">fold1</a><a href="#method.tree_fold1">tree_fold1</a><a href="#method.fold_while">fold_while</a><a href="#method.sorted">sorted</a><a href="#method.sorted_by">sorted_by</a><a href="#method.sorted_by_key">sorted_by_key</a><a href="#method.partition_map">partition_map</a><a href="#method.into_group_map">into_group_map</a><a href="#method.minmax">minmax</a><a href="#method.minmax_by_key">minmax_by_key</a><a href="#method.minmax_by">minmax_by</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='index.html'>itertools</a></p><script>window.sidebarCurrent = {name: 'Itertools', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></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">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content">
<h1 class='fqn'><span class='in-band'>Trait <a href='index.html'>itertools</a>::<wbr><a class="trait" href=''>Itertools</a></span><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'>&#x2212;</span>]
</a>
</span><a class='srclink' href='../src/itertools/lib.rs.html#283-1986' title='goto source code'>[src]</a></span></h1>
<pre class='rust trait'>pub trait Itertools: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> {
fn <a href='#method.interleave' class='fnname'>interleave</a>&lt;J&gt;(self, other: J) -&gt; <a class="struct" href="../itertools/structs/struct.Interleave.html" title="struct itertools::structs::Interleave">Interleave</a>&lt;Self, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&lt;Item = Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.interleave_shortest' class='fnname'>interleave_shortest</a>&lt;J&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;other: J<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="struct" href="../itertools/structs/struct.InterleaveShortest.html" title="struct itertools::structs::InterleaveShortest">InterleaveShortest</a>&lt;Self, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&lt;Item = Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.intersperse' class='fnname'>intersperse</a>(self, element: Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="struct" href="../itertools/structs/struct.Intersperse.html" title="struct itertools::structs::Intersperse">Intersperse</a>&lt;Self&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.zip_longest' class='fnname'>zip_longest</a>&lt;J&gt;(self, other: J) -&gt; <a class="struct" href="../itertools/structs/struct.ZipLongest.html" title="struct itertools::structs::ZipLongest">ZipLongest</a>&lt;Self, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.zip_eq' class='fnname'>zip_eq</a>&lt;J&gt;(self, other: J) -&gt; <a class="struct" href="../itertools/structs/struct.ZipEq.html" title="struct itertools::structs::ZipEq">ZipEq</a>&lt;Self, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.batching' class='fnname'>batching</a>&lt;B, F&gt;(self, f: F) -&gt; <a class="struct" href="../itertools/structs/struct.Batching.html" title="struct itertools::structs::Batching">Batching</a>&lt;Self, F&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;B&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.group_by' class='fnname'>group_by</a>&lt;K, F&gt;(self, key: F) -&gt; <a class="struct" href="../itertools/structs/struct.GroupBy.html" title="struct itertools::structs::GroupBy">GroupBy</a>&lt;K, Self, F&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; K,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.chunks' class='fnname'>chunks</a>(self, size: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="struct" href="../itertools/structs/struct.IntoChunks.html" title="struct itertools::structs::IntoChunks">IntoChunks</a>&lt;Self&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.tuple_windows' class='fnname'>tuple_windows</a>&lt;T&gt;(self) -&gt; <a class="struct" href="../itertools/structs/struct.TupleWindows.html" title="struct itertools::structs::TupleWindows">TupleWindows</a>&lt;Self, T&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = T::Item&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T: TupleCollect,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T::Item: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.tuples' class='fnname'>tuples</a>&lt;T&gt;(self) -&gt; <a class="struct" href="../itertools/structs/struct.Tuples.html" title="struct itertools::structs::Tuples">Tuples</a>&lt;Self, T&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = T::Item&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T: TupleCollect</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.tee' class='fnname'>tee</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="struct" href="../itertools/structs/struct.Tee.html" title="struct itertools::structs::Tee">Tee</a>&lt;Self&gt;, <a class="struct" href="../itertools/structs/struct.Tee.html" title="struct itertools::structs::Tee">Tee</a>&lt;Self&gt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.step' class='fnname'>step</a>(self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="struct" href="../itertools/structs/struct.Step.html" title="struct itertools::structs::Step">Step</a>&lt;Self&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.map_results' class='fnname'>map_results</a>&lt;F, T, U, E&gt;(self, f: F) -&gt; <a class="struct" href="../itertools/structs/struct.MapResults.html" title="struct itertools::structs::MapResults">MapResults</a>&lt;Self, F&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, E&gt;&gt; + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(T) -&gt; U</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.merge' class='fnname'>merge</a>&lt;J&gt;(self, other: J) -&gt; <a class="struct" href="../itertools/structs/struct.Merge.html" title="struct itertools::structs::Merge">Merge</a>&lt;Self, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&lt;Item = Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.merge_by' class='fnname'>merge_by</a>&lt;J, F&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;other: J, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;is_first: F<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="struct" href="../itertools/structs/struct.MergeBy.html" title="struct itertools::structs::MergeBy">MergeBy</a>&lt;Self, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>, F&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&lt;Item = Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, &amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.merge_join_by' class='fnname'>merge_join_by</a>&lt;J, F&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;other: J, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;cmp_fn: F<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="struct" href="../itertools/structs/struct.MergeJoinBy.html" title="struct itertools::structs::MergeJoinBy">MergeJoinBy</a>&lt;Self, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>, F&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, &amp;J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.Item" title="type core::iter::traits::IntoIterator::Item">Item</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.kmerge' class='fnname'>kmerge</a>(self) -&gt; <a class="struct" href="../itertools/structs/struct.KMerge.html" title="struct itertools::structs::KMerge">KMerge</a>&lt;&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.Item" title="type core::iter::traits::IntoIterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.kmerge_by' class='fnname'>kmerge_by</a>&lt;F&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;first: F<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="struct" href="../itertools/structs/struct.KMergeBy.html" title="struct itertools::structs::KMergeBy">KMergeBy</a>&lt;&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>, F&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.Item" title="type core::iter::traits::IntoIterator::Item">Item</a>, &amp;&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.Item" title="type core::iter::traits::IntoIterator::Item">Item</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.cartesian_product' class='fnname'>cartesian_product</a>&lt;J&gt;(self, other: J) -&gt; <a class="struct" href="../itertools/structs/struct.Product.html" title="struct itertools::structs::Product">Product</a>&lt;Self, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.multi_cartesian_product' class='fnname'>multi_cartesian_product</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="struct" href="../itertools/structs/struct.MultiProduct.html" title="struct itertools::structs::MultiProduct">MultiProduct</a>&lt;&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.Item" title="type core::iter::traits::IntoIterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.coalesce' class='fnname'>coalesce</a>&lt;F&gt;(self, f: F) -&gt; <a class="struct" href="../itertools/structs/struct.Coalesce.html" title="struct itertools::structs::Coalesce">Coalesce</a>&lt;Self, F&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>&gt;</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.dedup' class='fnname'>dedup</a>(self) -&gt; <a class="struct" href="../itertools/structs/struct.Dedup.html" title="struct itertools::structs::Dedup">Dedup</a>&lt;Self&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.unique' class='fnname'>unique</a>(self) -&gt; <a class="struct" href="../itertools/structs/struct.Unique.html" title="struct itertools::structs::Unique">Unique</a>&lt;Self&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.unique_by' class='fnname'>unique_by</a>&lt;V, F&gt;(self, f: F) -&gt; <a class="struct" href="../itertools/structs/struct.UniqueBy.html" title="struct itertools::structs::UniqueBy">UniqueBy</a>&lt;Self, V, F&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;V: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; V</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.peeking_take_while' class='fnname'>peeking_take_while</a>&lt;F&gt;(&amp;mut self, accept: F) -&gt; <a class="struct" href="../itertools/structs/struct.PeekingTakeWhile.html" title="struct itertools::structs::PeekingTakeWhile">PeekingTakeWhile</a>&lt;Self, F&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../itertools/trait.PeekingNext.html" title="trait itertools::PeekingNext">PeekingNext</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.take_while_ref' class='fnname'>take_while_ref</a>&lt;F&gt;(&amp;mut self, accept: F) -&gt; <a class="struct" href="../itertools/structs/struct.TakeWhileRef.html" title="struct itertools::structs::TakeWhileRef">TakeWhileRef</a>&lt;Self, F&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.while_some' class='fnname'>while_some</a>&lt;A&gt;(self) -&gt; <a class="struct" href="../itertools/structs/struct.WhileSome.html" title="struct itertools::structs::WhileSome">WhileSome</a>&lt;Self&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;A&gt;&gt;</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.tuple_combinations' class='fnname'>tuple_combinations</a>&lt;T&gt;(self) -&gt; <a class="struct" href="../itertools/structs/struct.TupleCombinations.html" title="struct itertools::structs::TupleCombinations">TupleCombinations</a>&lt;Self, T&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T: HasCombination&lt;Self&gt;</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.combinations' class='fnname'>combinations</a>(self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="struct" href="../itertools/structs/struct.Combinations.html" title="struct itertools::structs::Combinations">Combinations</a>&lt;Self&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.pad_using' class='fnname'>pad_using</a>&lt;F&gt;(self, min: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, f: F) -&gt; <a class="struct" href="../itertools/structs/struct.PadUsing.html" title="struct itertools::structs::PadUsing">PadUsing</a>&lt;Self, F&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.flatten' class='fnname'>flatten</a>(self) -&gt; <a class="struct" href="../itertools/structs/struct.Flatten.html" title="struct itertools::structs::Flatten">Flatten</a>&lt;Self, &lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.with_position' class='fnname'>with_position</a>(self) -&gt; <a class="struct" href="../itertools/structs/struct.WithPosition.html" title="struct itertools::structs::WithPosition">WithPosition</a>&lt;Self&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.positions' class='fnname'>positions</a>&lt;P&gt;(self, predicate: P) -&gt; <a class="struct" href="../itertools/structs/struct.Positions.html" title="struct itertools::structs::Positions">Positions</a>&lt;Self, P&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.update' class='fnname'>update</a>&lt;F&gt;(self, updater: F) -&gt; <a class="struct" href="../itertools/structs/struct.Update.html" title="struct itertools::structs::Update">Update</a>&lt;Self, F&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;mut Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>)</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.next_tuple' class='fnname'>next_tuple</a>&lt;T&gt;(&amp;mut self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;T&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = T::Item&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T: TupleCollect</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.collect_tuple' class='fnname'>collect_tuple</a>&lt;T&gt;(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;T&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = T::Item&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T: TupleCollect</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.find_position' class='fnname'>find_position</a>&lt;P&gt;(&amp;mut self, pred: P) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.all_equal' class='fnname'>all_equal</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.dropping' class='fnname'>dropping</a>(self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; Self<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.dropping_back' class='fnname'>dropping_back</a>(self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; Self<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.DoubleEndedIterator.html" title="trait core::iter::traits::DoubleEndedIterator">DoubleEndedIterator</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.foreach' class='fnname'>foreach</a>&lt;F&gt;(self, f: F)<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.concat' class='fnname'>concat</a>(self) -&gt; Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.Extend.html" title="trait core::iter::traits::Extend">Extend</a>&lt;&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.Item" title="type core::iter::traits::IntoIterator::Item">Item</a>&gt; + <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.collect_vec' class='fnname'>collect_vec</a>(self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.set_from' class='fnname'>set_from</a>&lt;'a, A:&nbsp;'a, J&gt;(&amp;mut self, from: J) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;'a mut </a>A&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&lt;Item = A&gt;</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.join' class='fnname'>join</a>(&amp;mut self, sep: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.format' class='fnname'>format</a>(self, sep: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="struct" href="../itertools/structs/struct.Format.html" title="struct itertools::structs::Format">Format</a>&lt;Self&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.format_with' class='fnname'>format_with</a>&lt;F&gt;(self, sep: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, format: F) -&gt; <a class="struct" href="../itertools/structs/struct.FormatWith.html" title="struct itertools::structs::FormatWith">FormatWith</a>&lt;Self, F&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, &amp;mut <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.fold_results' class='fnname'>fold_results</a>&lt;A, E, B, F&gt;(&amp;mut self, start: B, f: F) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;B, E&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;A, E&gt;&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(B, A) -&gt; B</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.fold_options' class='fnname'>fold_options</a>&lt;A, B, F&gt;(&amp;mut self, start: B, f: F) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;B&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;A&gt;&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(B, A) -&gt; B</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.fold1' class='fnname'>fold1</a>&lt;F&gt;(self, f: F) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.tree_fold1' class='fnname'>tree_fold1</a>&lt;F&gt;(self, f: F) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.fold_while' class='fnname'>fold_while</a>&lt;B, F&gt;(&amp;mut self, init: B, f: F) -&gt; <a class="enum" href="../itertools/enum.FoldWhile.html" title="enum itertools::FoldWhile">FoldWhile</a>&lt;B&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(B, Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="enum" href="../itertools/enum.FoldWhile.html" title="enum itertools::FoldWhile">FoldWhile</a>&lt;B&gt;</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.sorted' class='fnname'>sorted</a>(self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.sorted_by' class='fnname'>sorted_by</a>&lt;F&gt;(self, cmp: F) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, &amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.sorted_by_key' class='fnname'>sorted_by_key</a>&lt;K, F&gt;(self, f: F) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; K</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.partition_map' class='fnname'>partition_map</a>&lt;A, B, F, L, R&gt;(self, predicate: F) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>A, B<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a><br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="enum" href="../itertools/enum.Either.html" title="enum itertools::Either">Either</a>&lt;L, R&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A: <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.Extend.html" title="trait core::iter::traits::Extend">Extend</a>&lt;L&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.Extend.html" title="trait core::iter::traits::Extend">Extend</a>&lt;R&gt;</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.into_group_map' class='fnname'>into_group_map</a>&lt;K, V&gt;(self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/std/collections/hash/map/struct.HashMap.html" title="struct std::collections::hash::map::HashMap">HashMap</a>&lt;K, <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;V&gt;&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>K, V<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>&gt; + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.minmax' class='fnname'>minmax</a>(self) -&gt; <a class="enum" href="../itertools/enum.MinMaxResult.html" title="enum itertools::MinMaxResult">MinMaxResult</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a></span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.minmax_by_key' class='fnname'>minmax_by_key</a>&lt;K, F&gt;(self, key: F) -&gt; <a class="enum" href="../itertools/enum.MinMaxResult.html" title="enum itertools::MinMaxResult">MinMaxResult</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; K</span>,
{ ... }
<div class='item-spacer'></div> fn <a href='#method.minmax_by' class='fnname'>minmax_by</a>&lt;F&gt;(self, compare: F) -&gt; <a class="enum" href="../itertools/enum.MinMaxResult.html" title="enum itertools::MinMaxResult">MinMaxResult</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, &amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a></span>,
{ ... }
}</pre><div class='docblock'><p>The trait <code>Itertools</code>: extra iterator adaptors and methods for iterators.</p>
<p>This trait defines a number of methods. They are divided into two groups:</p>
<ul>
<li>
<p><em>Adaptors</em> take an iterator and parameter as input, and return
a new iterator value. These are listed first in the trait. An example
of an adaptor is <a href="#method.interleave"><code>.interleave()</code></a></p>
</li>
<li>
<p><em>Regular methods</em> are those that don't return iterators and instead
return a regular value of some other kind.
<a href="#method.next_tuple"><code>.next_tuple()</code></a> is an example and the first regular
method in the list.</p>
</li>
</ul>
</div>
<h2 id='provided-methods' class='small-section-header'>
Provided Methods<a href='#provided-methods' class='anchor'></a>
</h2>
<div class='methods'>
<div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.Interleave.html" title="struct itertools::structs::Interleave">Interleave</a>&lt;I, J&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.Interleave.html" title="struct itertools::structs::Interleave">Interleave</a>&lt;I, J&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, J&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.Interleave.html" title="struct itertools::structs::Interleave">Interleave</a>&lt;I, J&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>;</span></code></div></div><h3 id='method.interleave' class='method'><span id='interleave.v' class='invisible'><code>fn <a href='#method.interleave' class='fnname'>interleave</a>&lt;J&gt;(self, other: J) -&gt; <a class="struct" href="../itertools/structs/struct.Interleave.html" title="struct itertools::structs::Interleave">Interleave</a>&lt;Self, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&lt;Item = Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Alternate elements from two iterators until both have run out.</p>
<p>Iterator element type is <code>Self::Item</code>.</p>
<p>This iterator is <em>fused</em>.</p>
<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">7</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>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.InterleaveShortest.html" title="struct itertools::structs::InterleaveShortest">InterleaveShortest</a>&lt;I, J&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.InterleaveShortest.html" title="struct itertools::structs::InterleaveShortest">InterleaveShortest</a>&lt;I, J&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, J&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.InterleaveShortest.html" title="struct itertools::structs::InterleaveShortest">InterleaveShortest</a>&lt;I, J&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>;</span></code></div></div><h3 id='method.interleave_shortest' class='method'><span id='interleave_shortest.v' class='invisible'><code>fn <a href='#method.interleave_shortest' class='fnname'>interleave_shortest</a>&lt;J&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;other: J<br>) -&gt; <a class="struct" href="../itertools/structs/struct.InterleaveShortest.html" title="struct itertools::structs::InterleaveShortest">InterleaveShortest</a>&lt;Self, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&lt;Item = Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Alternate elements from two iterators until at least one of them has run
out.</p>
<p>Iterator element type is <code>Self::Item</code>.</p>
<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">7</span>).<span class="ident">interleave_shortest</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>, <span class="number">3</span>]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.Intersperse.html" title="struct itertools::structs::Intersperse">Intersperse</a>&lt;I&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.Intersperse.html" title="struct itertools::structs::Intersperse">Intersperse</a>&lt;I&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.Intersperse.html" title="struct itertools::structs::Intersperse">Intersperse</a>&lt;I&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>;</span></code></div></div><h3 id='method.intersperse' class='method'><span id='intersperse.v' class='invisible'><code>fn <a href='#method.intersperse' class='fnname'>intersperse</a>(self, element: Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="struct" href="../itertools/structs/struct.Intersperse.html" title="struct itertools::structs::Intersperse">Intersperse</a>&lt;Self&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>An iterator adaptor to insert a particular value
between each element of the adapted iterator.</p>
<p>Iterator element type is <code>Self::Item</code>.</p>
<p>This iterator is <em>fused</em>.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>((<span class="number">0</span>..<span class="number">3</span>).<span class="ident">intersperse</span>(<span class="number">8</span>), <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>, <span class="number">8</span>, <span class="number">1</span>, <span class="number">8</span>, <span class="number">2</span>]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.ZipLongest.html" title="struct itertools::structs::ZipLongest">ZipLongest</a>&lt;T, U&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.ZipLongest.html" title="struct itertools::structs::ZipLongest">ZipLongest</a>&lt;T, U&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.ZipLongest.html" title="struct itertools::structs::ZipLongest">ZipLongest</a>&lt;T, U&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="enum" href="../itertools/enum.EitherOrBoth.html" title="enum itertools::EitherOrBoth">EitherOrBoth</a>&lt;T::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, U::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;;</span></code></div></div><h3 id='method.zip_longest' class='method'><span id='zip_longest.v' class='invisible'><code>fn <a href='#method.zip_longest' class='fnname'>zip_longest</a>&lt;J&gt;(self, other: J) -&gt; <a class="struct" href="../itertools/structs/struct.ZipLongest.html" title="struct itertools::structs::ZipLongest">ZipLongest</a>&lt;Self, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Create an iterator which iterates over both this and the specified
iterator simultaneously, yielding pairs of two optional elements.</p>
<p>This iterator is <em>fused</em>.</p>
<p>As long as neither input iterator is exhausted yet, it yields two values
via <code>EitherOrBoth::Both</code>.</p>
<p>When the parameter iterator is exhausted, it only yields a value from the
<code>self</code> iterator via <code>EitherOrBoth::Left</code>.</p>
<p>When the <code>self</code> iterator is exhausted, it only yields a value from the
parameter iterator via <code>EitherOrBoth::Right</code>.</p>
<p>When both iterators return <code>None</code>, all further invocations of <code>.next()</code>
will return <code>None</code>.</p>
<p>Iterator element type is
<a href="enum.EitherOrBoth.html"><code>EitherOrBoth&lt;Self::Item, J::Item&gt;</code></a>.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">EitherOrBoth</span>::{<span class="ident">Both</span>, <span class="ident">Right</span>};
<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">0</span>..<span class="number">1</span>).<span class="ident">zip_longest</span>(<span class="number">1</span>..<span class="number">3</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="ident">Both</span>(<span class="number">0</span>, <span class="number">1</span>), <span class="ident">Right</span>(<span class="number">2</span>)]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.ZipEq.html" title="struct itertools::structs::ZipEq">ZipEq</a>&lt;I, J&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.ZipEq.html" title="struct itertools::structs::ZipEq">ZipEq</a>&lt;I, J&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, J&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.ZipEq.html" title="struct itertools::structs::ZipEq">ZipEq</a>&lt;I, J&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>;</span></code></div></div><h3 id='method.zip_eq' class='method'><span id='zip_eq.v' class='invisible'><code>fn <a href='#method.zip_eq' class='fnname'>zip_eq</a>&lt;J&gt;(self, other: J) -&gt; <a class="struct" href="../itertools/structs/struct.ZipEq.html" title="struct itertools::structs::ZipEq">ZipEq</a>&lt;Self, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Create an iterator which iterates over both this and the specified
iterator simultaneously, yielding pairs of elements.</p>
<p><strong>Panics</strong> if the iterators reach an end and they are not of equal
lengths.</p>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.Batching.html" title="struct itertools::structs::Batching">Batching</a>&lt;I, F&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.Batching.html" title="struct itertools::structs::Batching">Batching</a>&lt;I, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;B, F, I&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.Batching.html" title="struct itertools::structs::Batching">Batching</a>&lt;I, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>I) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;B&gt;,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = B;</span></code></div></div><h3 id='method.batching' class='method'><span id='batching.v' class='invisible'><code>fn <a href='#method.batching' class='fnname'>batching</a>&lt;B, F&gt;(self, f: F) -&gt; <a class="struct" href="../itertools/structs/struct.Batching.html" title="struct itertools::structs::Batching">Batching</a>&lt;Self, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>Self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;B&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>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.</p>
<p>Iterator element type is <code>B</code>.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
<span class="comment">// An adaptor that gathers elements in pairs</span>
<span class="kw">let</span> <span class="ident">pit</span> <span class="op">=</span> (<span class="number">0</span>..<span class="number">4</span>).<span class="ident">batching</span>(<span class="op">|</span><span class="ident">it</span><span class="op">|</span> {
<span class="kw">match</span> <span class="ident">it</span>.<span class="ident">next</span>() {
<span class="prelude-val">None</span> <span class="op">=&gt;</span> <span class="prelude-val">None</span>,
<span class="prelude-val">Some</span>(<span class="ident">x</span>) <span class="op">=&gt;</span> <span class="kw">match</span> <span class="ident">it</span>.<span class="ident">next</span>() {
<span class="prelude-val">None</span> <span class="op">=&gt;</span> <span class="prelude-val">None</span>,
<span class="prelude-val">Some</span>(<span class="ident">y</span>) <span class="op">=&gt;</span> <span class="prelude-val">Some</span>((<span class="ident">x</span>, <span class="ident">y</span>)),
}
}
});
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">pit</span>, <span class="macro">vec</span><span class="macro">!</span>[(<span class="number">0</span>, <span class="number">1</span>), (<span class="number">2</span>, <span class="number">3</span>)]);</pre>
</div><h3 id='method.group_by' class='method'><span id='group_by.v' class='invisible'><code>fn <a href='#method.group_by' class='fnname'>group_by</a>&lt;K, F&gt;(self, key: F) -&gt; <a class="struct" href="../itertools/structs/struct.GroupBy.html" title="struct itertools::structs::GroupBy">GroupBy</a>&lt;K, Self, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; K,<br>&nbsp;&nbsp;&nbsp;&nbsp;K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Return an <em>iterable</em> that can group iterator elements.
Consecutive elements that map to the same key (“runs”), are assigned
to the same group.</p>
<p><code>GroupBy</code> is the storage for the lazy grouping operation.</p>
<p>If the groups are consumed in order, or if each group's iterator is
dropped without keeping it around, then <code>GroupBy</code> uses no
allocations. It needs allocations only if several group iterators
are alive at the same time.</p>
<p>This type implements <code>IntoIterator</code> (it is <strong>not</strong> an iterator
itself), because the group iterators need to borrow from this
value. It should be stored in a local variable or temporary and
iterated.</p>
<p>Iterator element type is <code>(K, Group)</code>: the group's key and the
group iterator.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
<span class="comment">// group data into runs of larger than zero or not.</span>
<span class="kw">let</span> <span class="ident">data</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">3</span>, <span class="op">-</span><span class="number">2</span>, <span class="op">-</span><span class="number">2</span>, <span class="number">1</span>, <span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>];
<span class="comment">// groups: |----&gt;|------&gt;|---------&gt;|</span>
<span class="comment">// Note: The `&amp;` is significant here, `GroupBy` is iterable</span>
<span class="comment">// only by reference. You can also call `.into_iter()` explicitly.</span>
<span class="kw">for</span> (<span class="ident">key</span>, <span class="ident">group</span>) <span class="kw">in</span> <span class="kw-2">&amp;</span><span class="ident">data</span>.<span class="ident">into_iter</span>().<span class="ident">group_by</span>(<span class="op">|</span><span class="ident">elt</span><span class="op">|</span> <span class="kw-2">*</span><span class="ident">elt</span> <span class="op">&gt;=</span> <span class="number">0</span>) {
<span class="comment">// Check that the sum of each group is +/- 4.</span>
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">4</span>, <span class="ident">group</span>.<span class="ident">sum</span>::<span class="op">&lt;</span><span class="ident">i32</span><span class="op">&gt;</span>().<span class="ident">abs</span>());
}</pre>
</div><h3 id='method.chunks' class='method'><span id='chunks.v' class='invisible'><code>fn <a href='#method.chunks' class='fnname'>chunks</a>(self, size: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="struct" href="../itertools/structs/struct.IntoChunks.html" title="struct itertools::structs::IntoChunks">IntoChunks</a>&lt;Self&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Return an <em>iterable</em> that can chunk the iterator.</p>
<p>Yield subiterators (chunks) that each yield a fixed number elements,
determined by <code>size</code>. The last chunk will be shorter if there aren't
enough elements.</p>
<p><code>IntoChunks</code> is based on <code>GroupBy</code>: it is iterable (implements
<code>IntoIterator</code>, <strong>not</strong> <code>Iterator</code>), and it only buffers if several
chunk iterators are alive at the same time.</p>
<p>Iterator element type is <code>Chunk</code>, each chunk's iterator.</p>
<p><strong>Panics</strong> if <code>size</code> is 0.</p>
<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">data</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="op">-</span><span class="number">2</span>, <span class="number">6</span>, <span class="number">0</span>, <span class="number">3</span>, <span class="number">1</span>];
<span class="comment">//chunk size=3 |-------&gt;|--------&gt;|---&gt;|</span>
<span class="comment">// Note: The `&amp;` is significant here, `IntoChunks` is iterable</span>
<span class="comment">// only by reference. You can also call `.into_iter()` explicitly.</span>
<span class="kw">for</span> <span class="ident">chunk</span> <span class="kw">in</span> <span class="kw-2">&amp;</span><span class="ident">data</span>.<span class="ident">into_iter</span>().<span class="ident">chunks</span>(<span class="number">3</span>) {
<span class="comment">// Check that the sum of each chunk is 4.</span>
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">4</span>, <span class="ident">chunk</span>.<span class="ident">sum</span>());
}</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.TupleWindows.html" title="struct itertools::structs::TupleWindows">TupleWindows</a>&lt;I, T&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.TupleWindows.html" title="struct itertools::structs::TupleWindows">TupleWindows</a>&lt;I, T&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.TupleWindows.html" title="struct itertools::structs::TupleWindows">TupleWindows</a>&lt;I, T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = T::Item&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;T: TupleCollect + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;T::Item: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = T;</span></code></div></div><h3 id='method.tuple_windows' class='method'><span id='tuple_windows.v' class='invisible'><code>fn <a href='#method.tuple_windows' class='fnname'>tuple_windows</a>&lt;T&gt;(self) -&gt; <a class="struct" href="../itertools/structs/struct.TupleWindows.html" title="struct itertools::structs::TupleWindows">TupleWindows</a>&lt;Self, T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = T::Item&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;T: TupleCollect,<br>&nbsp;&nbsp;&nbsp;&nbsp;T::Item: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Return an iterator over all contiguous windows producing tuples of
a specific size (up to 4).</p>
<p><code>tuple_windows</code> clones the iterator elements so that they can be
part of successive windows, this makes it most suited for iterators
of references and other values that are cheap to copy.</p>
<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="kw-2">mut</span> <span class="ident">v</span> <span class="op">=</span> <span class="ident">Vec</span>::<span class="ident">new</span>();
<span class="kw">for</span> (<span class="ident">a</span>, <span class="ident">b</span>) <span class="kw">in</span> (<span class="number">1</span>..<span class="number">5</span>).<span class="ident">tuple_windows</span>() {
<span class="ident">v</span>.<span class="ident">push</span>((<span class="ident">a</span>, <span class="ident">b</span>));
}
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">v</span>, <span class="macro">vec</span><span class="macro">!</span>[(<span class="number">1</span>, <span class="number">2</span>), (<span class="number">2</span>, <span class="number">3</span>), (<span class="number">3</span>, <span class="number">4</span>)]);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">it</span> <span class="op">=</span> (<span class="number">1</span>..<span class="number">5</span>).<span class="ident">tuple_windows</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>((<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>)), <span class="ident">it</span>.<span class="ident">next</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>((<span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>)), <span class="ident">it</span>.<span class="ident">next</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">None</span>, <span class="ident">it</span>.<span class="ident">next</span>());
<span class="comment">// this requires a type hint</span>
<span class="kw">let</span> <span class="ident">it</span> <span class="op">=</span> (<span class="number">1</span>..<span class="number">5</span>).<span class="ident">tuple_windows</span>::<span class="op">&lt;</span>(_, _, _)<span class="op">&gt;</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="number">2</span>, <span class="number">3</span>), (<span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>)]);
<span class="comment">// you can also specify the complete type</span>
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">TupleWindows</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ops</span>::<span class="ident">Range</span>;
<span class="kw">let</span> <span class="ident">it</span>: <span class="ident">TupleWindows</span><span class="op">&lt;</span><span class="ident">Range</span><span class="op">&lt;</span><span class="ident">u32</span><span class="op">&gt;</span>, (<span class="ident">u32</span>, <span class="ident">u32</span>, <span class="ident">u32</span>)<span class="op">&gt;</span> <span class="op">=</span> (<span class="number">1</span>..<span class="number">5</span>).<span class="ident">tuple_windows</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="number">2</span>, <span class="number">3</span>), (<span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>)]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.Tuples.html" title="struct itertools::structs::Tuples">Tuples</a>&lt;I, T&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.Tuples.html" title="struct itertools::structs::Tuples">Tuples</a>&lt;I, T&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.Tuples.html" title="struct itertools::structs::Tuples">Tuples</a>&lt;I, T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = T::Item&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;T: TupleCollect,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = T;</span></code></div></div><h3 id='method.tuples' class='method'><span id='tuples.v' class='invisible'><code>fn <a href='#method.tuples' class='fnname'>tuples</a>&lt;T&gt;(self) -&gt; <a class="struct" href="../itertools/structs/struct.Tuples.html" title="struct itertools::structs::Tuples">Tuples</a>&lt;Self, T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = T::Item&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;T: TupleCollect,&nbsp;</span></code></span></h3><div class='docblock'><p>Return an iterator that groups the items in tuples of a specific size
(up to 4).</p>
<p>See also the method <a href="#method.next_tuple"><code>.next_tuple()</code></a>.</p>
<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="kw-2">mut</span> <span class="ident">v</span> <span class="op">=</span> <span class="ident">Vec</span>::<span class="ident">new</span>();
<span class="kw">for</span> (<span class="ident">a</span>, <span class="ident">b</span>) <span class="kw">in</span> (<span class="number">1</span>..<span class="number">5</span>).<span class="ident">tuples</span>() {
<span class="ident">v</span>.<span class="ident">push</span>((<span class="ident">a</span>, <span class="ident">b</span>));
}
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">v</span>, <span class="macro">vec</span><span class="macro">!</span>[(<span class="number">1</span>, <span class="number">2</span>), (<span class="number">3</span>, <span class="number">4</span>)]);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">it</span> <span class="op">=</span> (<span class="number">1</span>..<span class="number">7</span>).<span class="ident">tuples</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>((<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>)), <span class="ident">it</span>.<span class="ident">next</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>((<span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>)), <span class="ident">it</span>.<span class="ident">next</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">None</span>, <span class="ident">it</span>.<span class="ident">next</span>());
<span class="comment">// this requires a type hint</span>
<span class="kw">let</span> <span class="ident">it</span> <span class="op">=</span> (<span class="number">1</span>..<span class="number">7</span>).<span class="ident">tuples</span>::<span class="op">&lt;</span>(_, _, _)<span class="op">&gt;</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="number">2</span>, <span class="number">3</span>), (<span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>)]);
<span class="comment">// you can also specify the complete type</span>
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Tuples</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ops</span>::<span class="ident">Range</span>;
<span class="kw">let</span> <span class="ident">it</span>: <span class="ident">Tuples</span><span class="op">&lt;</span><span class="ident">Range</span><span class="op">&lt;</span><span class="ident">u32</span><span class="op">&gt;</span>, (<span class="ident">u32</span>, <span class="ident">u32</span>, <span class="ident">u32</span>)<span class="op">&gt;</span> <span class="op">=</span> (<span class="number">1</span>..<span class="number">7</span>).<span class="ident">tuples</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="number">2</span>, <span class="number">3</span>), (<span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>)]);</pre>
<p>See also <a href="structs/struct.Tuples.html#method.into_buffer"><code>Tuples::into_buffer</code></a>.</p>
</div><h3 id='method.tee' class='method'><span id='tee.v' class='invisible'><code>fn <a href='#method.tee' class='fnname'>tee</a>(self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="struct" href="../itertools/structs/struct.Tee.html" title="struct itertools::structs::Tee">Tee</a>&lt;Self&gt;, <a class="struct" href="../itertools/structs/struct.Tee.html" title="struct itertools::structs::Tee">Tee</a>&lt;Self&gt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Split into an iterator pair that both yield all elements from
the original iterator.</p>
<p><strong>Note:</strong> If the iterator is clonable, prefer using that instead
of using this method. It is likely to be more efficient.</p>
<p>Iterator element type is <code>Self::Item</code>.</p>
<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">xs</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>];
<span class="kw">let</span> (<span class="kw-2">mut</span> <span class="ident">t1</span>, <span class="ident">t2</span>) <span class="op">=</span> <span class="ident">xs</span>.<span class="ident">into_iter</span>().<span class="ident">tee</span>();
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">t1</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="number">0</span>));
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">t2</span>, <span class="number">0</span>..<span class="number">4</span>);
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">t1</span>, <span class="number">1</span>..<span class="number">4</span>);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.Step.html" title="struct itertools::structs::Step">Step</a>&lt;I&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.Step.html" title="struct itertools::structs::Step">Step</a>&lt;I&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.Step.html" title="struct itertools::structs::Step">Step</a>&lt;I&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>;</span></code></div></div><h3 id='method.step' class='method'><span id='step.v' class='invisible'><code>fn <a href='#method.step' class='fnname'>step</a>(self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="struct" href="../itertools/structs/struct.Step.html" title="struct itertools::structs::Step">Step</a>&lt;Self&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Return an iterator adaptor that steps <code>n</code> elements in the base iterator
for each iteration.</p>
<p>The iterator steps by yielding the next element from the base iterator,
then skipping forward <code>n - 1</code> elements.</p>
<p>Iterator element type is <code>Self::Item</code>.</p>
<p><strong>Panics</strong> if the step is 0.</p>
<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">0</span>..<span class="number">8</span>).<span class="ident">step</span>(<span class="number">3</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">0</span>, <span class="number">3</span>, <span class="number">6</span>]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.MapResults.html" title="struct itertools::structs::MapResults">MapResults</a>&lt;I, F&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.MapResults.html" title="struct itertools::structs::MapResults">MapResults</a>&lt;I, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, F, T, U, E&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.MapResults.html" title="struct itertools::structs::MapResults">MapResults</a>&lt;I, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, E&gt;&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(T) -&gt; U,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, E&gt;;</span></code></div></div><h3 id='method.map_results' class='method'><span id='map_results.v' class='invisible'><code>fn <a href='#method.map_results' class='fnname'>map_results</a>&lt;F, T, U, E&gt;(self, f: F) -&gt; <a class="struct" href="../itertools/structs/struct.MapResults.html" title="struct itertools::structs::MapResults">MapResults</a>&lt;Self, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, E&gt;&gt; + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(T) -&gt; U,&nbsp;</span></code></span></h3><div class='docblock'><p>Return an iterator adaptor that applies the provided closure
to every <code>Result::Ok</code> value. <code>Result::Err</code> values are
unchanged.</p>
<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">input</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="prelude-val">Ok</span>(<span class="number">41</span>), <span class="prelude-val">Err</span>(<span class="bool-val">false</span>), <span class="prelude-val">Ok</span>(<span class="number">11</span>)];
<span class="kw">let</span> <span class="ident">it</span> <span class="op">=</span> <span class="ident">input</span>.<span class="ident">into_iter</span>().<span class="ident">map_results</span>(<span class="op">|</span><span class="ident">i</span><span class="op">|</span> <span class="ident">i</span> <span class="op">+</span> <span class="number">1</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="prelude-val">Ok</span>(<span class="number">42</span>), <span class="prelude-val">Err</span>(<span class="bool-val">false</span>), <span class="prelude-val">Ok</span>(<span class="number">12</span>)]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.Merge.html" title="struct itertools::structs::Merge">Merge</a>&lt;I, J&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.Merge.html" title="struct itertools::structs::Merge">Merge</a>&lt;I, J&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, J&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.Merge.html" title="struct itertools::structs::Merge">Merge</a>&lt;I, J&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>;</span></code></div></div><h3 id='method.merge' class='method'><span id='merge.v' class='invisible'><code>fn <a href='#method.merge' class='fnname'>merge</a>&lt;J&gt;(self, other: J) -&gt; <a class="struct" href="../itertools/structs/struct.Merge.html" title="struct itertools::structs::Merge">Merge</a>&lt;Self, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&lt;Item = Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;,&nbsp;</span></code></span></h3><div class='docblock'><p>Return an iterator adaptor that merges the two base iterators in
ascending order. If both base iterators are sorted (ascending), the
result is sorted.</p>
<p>Iterator element type is <code>Self::Item</code>.</p>
<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">a</span> <span class="op">=</span> (<span class="number">0</span>..<span class="number">11</span>).<span class="ident">step</span>(<span class="number">3</span>);
<span class="kw">let</span> <span class="ident">b</span> <span class="op">=</span> (<span class="number">0</span>..<span class="number">11</span>).<span class="ident">step</span>(<span class="number">5</span>);
<span class="kw">let</span> <span class="ident">it</span> <span class="op">=</span> <span class="ident">a</span>.<span class="ident">merge</span>(<span class="ident">b</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">0</span>, <span class="number">0</span>, <span class="number">3</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">9</span>, <span class="number">10</span>]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.MergeBy.html" title="struct itertools::structs::MergeBy">MergeBy</a>&lt;I, J, F&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.MergeBy.html" title="struct itertools::structs::MergeBy">MergeBy</a>&lt;I, J, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, J, F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.MergeBy.html" title="struct itertools::structs::MergeBy">MergeBy</a>&lt;I, J, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, &amp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>;</span></code></div></div><h3 id='method.merge_by' class='method'><span id='merge_by.v' class='invisible'><code>fn <a href='#method.merge_by' class='fnname'>merge_by</a>&lt;J, F&gt;(self, other: J, is_first: F) -&gt; <a class="struct" href="../itertools/structs/struct.MergeBy.html" title="struct itertools::structs::MergeBy">MergeBy</a>&lt;Self, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&lt;Item = Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, &amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::ite
This is much like <code>.merge()</code> but allows for a custom ordering.</p>
<p>This can be especially useful for sequences of tuples.</p>
<p>Iterator element type is <code>Self::Item</code>.</p>
<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">a</span> <span class="op">=</span> (<span class="number">0</span>..).<span class="ident">zip</span>(<span class="string">&quot;bc&quot;</span>.<span class="ident">chars</span>());
<span class="kw">let</span> <span class="ident">b</span> <span class="op">=</span> (<span class="number">0</span>..).<span class="ident">zip</span>(<span class="string">&quot;ad&quot;</span>.<span class="ident">chars</span>());
<span class="kw">let</span> <span class="ident">it</span> <span class="op">=</span> <span class="ident">a</span>.<span class="ident">merge_by</span>(<span class="ident">b</span>, <span class="op">|</span><span class="ident">x</span>, <span class="ident">y</span><span class="op">|</span> <span class="ident">x</span>.<span class="number">1</span> <span class="op">&lt;=</span> <span class="ident">y</span>.<span class="number">1</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">0</span>, <span class="string">&#39;a&#39;</span>), (<span class="number">0</span>, <span class="string">&#39;b&#39;</span>), (<span class="number">1</span>, <span class="string">&#39;c&#39;</span>), (<span class="number">1</span>, <span class="string">&#39;d&#39;</span>)]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.MergeJoinBy.html" title="struct itertools::structs::MergeJoinBy">MergeJoinBy</a>&lt;I, J, F&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.MergeJoinBy.html" title="struct itertools::structs::MergeJoinBy">MergeJoinBy</a>&lt;I, J, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, J, F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.MergeJoinBy.html" title="struct itertools::structs::MergeJoinBy">MergeJoinBy</a>&lt;I, J, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, &amp;J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="enum" href="../itertools/enum.EitherOrBoth.html" title="enum itertools::EitherOrBoth">EitherOrBoth</a>&lt;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;;</span></code></div></div><h3 id='method.merge_join_by' class='method'><span id='merge_join_by.v' class='invisible'><code>fn <a href='#method.merge_join_by' class='fnname'>merge_join_by</a>&lt;J, F&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;other: J, <br>&nbsp;&nbsp;&nbsp;&nbsp;cmp_fn: F<br>) -&gt; <a class="struct" href="../itertools/structs/struct.MergeJoinBy.html" title="struct itertools::structs::MergeJoinBy">MergeJoinBy</a>&lt;Self, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, &amp;J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.Item" title="type core::iter::traits::IntoIterator::Item">Item</a>) -&gt; <a class="enum" h
iterator in ascending order.</p>
<p>It chooses whether to pair elements based on the <code>Ordering</code> returned by the
specified compare function. At any point, inspecting the tip of the
iterators <code>I</code> and <code>J</code> as items <code>i</code> of type <code>I::Item</code> and <code>j</code> of type
<code>J::Item</code> respectively, the resulting iterator will:</p>
<ul>
<li>Emit <code>EitherOrBoth::Left(i)</code> when <code>i &lt; j</code>,
and remove <code>i</code> from its source iterator</li>
<li>Emit <code>EitherOrBoth::Right(j)</code> when <code>i &gt; j</code>,
and remove <code>j</code> from its source iterator</li>
<li>Emit <code>EitherOrBoth::Both(i, j)</code> when <code>i == j</code>,
and remove both <code>i</code> and <code>j</code> from their respective source iterators</li>
</ul>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">EitherOrBoth</span>::{<span class="ident">Left</span>, <span class="ident">Right</span>, <span class="ident">Both</span>};
<span class="kw">let</span> <span class="ident">ki</span> <span class="op">=</span> (<span class="number">0</span>..<span class="number">10</span>).<span class="ident">step</span>(<span class="number">3</span>);
<span class="kw">let</span> <span class="ident">ku</span> <span class="op">=</span> (<span class="number">0</span>..<span class="number">10</span>).<span class="ident">step</span>(<span class="number">5</span>);
<span class="kw">let</span> <span class="ident">ki_ku</span> <span class="op">=</span> <span class="ident">ki</span>.<span class="ident">merge_join_by</span>(<span class="ident">ku</span>, <span class="op">|</span><span class="ident">i</span>, <span class="ident">j</span><span class="op">|</span> <span class="ident">i</span>.<span class="ident">cmp</span>(<span class="ident">j</span>)).<span class="ident">map</span>(<span class="op">|</span><span class="ident">either</span><span class="op">|</span> {
<span class="kw">match</span> <span class="ident">either</span> {
<span class="ident">Left</span>(_) <span class="op">=&gt;</span> <span class="string">&quot;Ki&quot;</span>,
<span class="ident">Right</span>(_) <span class="op">=&gt;</span> <span class="string">&quot;Ku&quot;</span>,
<span class="ident">Both</span>(_, _) <span class="op">=&gt;</span> <span class="string">&quot;KiKu&quot;</span>
}
});
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">ki_ku</span>, <span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;KiKu&quot;</span>, <span class="string">&quot;Ki&quot;</span>, <span class="string">&quot;Ku&quot;</span>, <span class="string">&quot;Ki&quot;</span>, <span class="string">&quot;Ki&quot;</span>]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.KMerge.html" title="struct itertools::structs::KMerge">KMerge</a>&lt;I&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.KMerge.html" title="struct itertools::structs::KMerge">KMerge</a>&lt;I&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.KMerge.html" title="struct itertools::structs::KMerge">KMerge</a>&lt;I&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>;</span></code></div></div><h3 id='method.kmerge' class='method'><span id='kmerge.v' class='invisible'><code>fn <a href='#method.kmerge' class='fnname'>kmerge</a>(self) -&gt; <a class="struct" href="../itertools/structs/struct.KMerge.html" title="struct itertools::structs::KMerge">KMerge</a>&lt;&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.Item" title="type core::iter::traits::IntoIterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Return an iterator adaptor that flattens an iterator of iterators by
merging them in ascending order.</p>
<p>If all base iterators are sorted (ascending), the result is sorted.</p>
<p>Iterator element type is <code>Self::Item</code>.</p>
<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">a</span> <span class="op">=</span> (<span class="number">0</span>..<span class="number">6</span>).<span class="ident">step</span>(<span class="number">3</span>);
<span class="kw">let</span> <span class="ident">b</span> <span class="op">=</span> (<span class="number">1</span>..<span class="number">6</span>).<span class="ident">step</span>(<span class="number">3</span>);
<span class="kw">let</span> <span class="ident">c</span> <span class="op">=</span> (<span class="number">2</span>..<span class="number">6</span>).<span class="ident">step</span>(<span class="number">3</span>);
<span class="kw">let</span> <span class="ident">it</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="ident">a</span>, <span class="ident">b</span>, <span class="ident">c</span>].<span class="ident">into_iter</span>().<span class="ident">kmerge</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">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.KMergeBy.html" title="struct itertools::structs::KMergeBy">KMergeBy</a>&lt;I, F&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.KMergeBy.html" title="struct itertools::structs::KMergeBy">KMergeBy</a>&lt;I, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.KMergeBy.html" title="struct itertools::structs::KMergeBy">KMergeBy</a>&lt;I, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, &amp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>;</span></code></div></div><h3 id='method.kmerge_by' class='method'><span id='kmerge_by.v' class='invisible'><code>fn <a href='#method.kmerge_by' class='fnname'>kmerge_by</a>&lt;F&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;first: F<br>) -&gt; <a class="struct" href="../itertools/structs/struct.KMergeBy.html" title="struct itertools::structs::KMergeBy">KMergeBy</a>&lt;&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoItera
merging them according to the given closure.</p>
<p>The closure <code>first</code> is called with two elements <em>a</em>, <em>b</em> and should
return <code>true</code> if <em>a</em> is ordered before <em>b</em>.</p>
<p>If all base iterators are sorted according to <code>first</code>, the result is
sorted.</p>
<p>Iterator element type is <code>Self::Item</code>.</p>
<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">a</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="op">-</span><span class="number">1f64</span>, <span class="number">2.</span>, <span class="number">3.</span>, <span class="op">-</span><span class="number">5.</span>, <span class="number">6.</span>, <span class="op">-</span><span class="number">7.</span>];
<span class="kw">let</span> <span class="ident">b</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0.</span>, <span class="number">2.</span>, <span class="op">-</span><span class="number">4.</span>];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">it</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="ident">a</span>, <span class="ident">b</span>].<span class="ident">into_iter</span>().<span class="ident">kmerge_by</span>(<span class="op">|</span><span class="ident">a</span>, <span class="ident">b</span><span class="op">|</span> <span class="ident">a</span>.<span class="ident">abs</span>() <span class="op">&lt;</span> <span class="ident">b</span>.<span class="ident">abs</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">it</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="number">0.</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">it</span>.<span class="ident">last</span>(), <span class="prelude-val">Some</span>(<span class="op">-</span><span class="number">7.</span>));</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.Product.html" title="struct itertools::structs::Product">Product</a>&lt;I, J&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.Product.html" title="struct itertools::structs::Product">Product</a>&lt;I, J&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, J&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.Product.html" title="struct itertools::structs::Product">Product</a>&lt;I, J&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>;</span></code></div></div><h3 id='method.cartesian_product' class='method'><span id='cartesian_product.v' class='invisible'><code>fn <a href='#method.cartesian_product' class='fnname'>cartesian_product</a>&lt;J&gt;(self, other: J) -&gt; <a class="struct" href="../itertools/structs/struct.Product.html" title="struct itertools::structs::Product">Product</a>&lt;Self, J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,&nbsp;</span></
the element sets of two iterators <code>self</code> and <code>J</code>.</p>
<p>Iterator element type is <code>(Self::Item, J::Item)</code>.</p>
<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">0</span>..<span class="number">2</span>).<span class="ident">cartesian_product</span>(<span class="string">&quot;αβ&quot;</span>.<span class="ident">chars</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">0</span>, <span class="string">&#39;α&#39;</span>), (<span class="number">0</span>, <span class="string">&#39;β&#39;</span>), (<span class="number">1</span>, <span class="string">&#39;α&#39;</span>), (<span class="number">1</span>, <span class="string">&#39;β&#39;</span>)]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.MultiProduct.html" title="struct itertools::structs::MultiProduct">MultiProduct</a>&lt;I&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.MultiProduct.html" title="struct itertools::structs::MultiProduct">MultiProduct</a>&lt;I&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.MultiProduct.html" title="struct itertools::structs::MultiProduct">MultiProduct</a>&lt;I&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;;</span></code></div></div><h3 id='method.multi_cartesian_product' class='method'><span id='multi_cartesian_product.v' class='invisible'><code>fn <a href='#method.multi_cartesian_product' class='fnname'>multi_cartesian_product</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;self<br>) -&gt; <a class="struct" href="../itertools/structs/struct.MultiProduct.html" title="struct itertools::structs::MultiProduct">MultiProduct</a>&lt;&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIter
all subiterators returned by meta-iterator <code>self</code>.</p>
<p>All provided iterators must yield the same <code>Item</code> type. To generate
the product of iterators yielding multiple types, use the
<a href="macro.iproduct.html"><code>iproduct</code></a> macro instead.</p>
<p>The iterator element type is <code>Vec&lt;T&gt;</code>, where <code>T</code> is the iterator element
of the subiterators.</p>
<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="kw-2">mut</span> <span class="ident">multi_prod</span> <span class="op">=</span> (<span class="number">0</span>..<span class="number">3</span>).<span class="ident">map</span>(<span class="op">|</span><span class="ident">i</span><span class="op">|</span> (<span class="ident">i</span> <span class="op">*</span> <span class="number">2</span>)..(<span class="ident">i</span> <span class="op">*</span> <span class="number">2</span> <span class="op">+</span> <span class="number">2</span>))
.<span class="ident">multi_cartesian_product</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">multi_prod</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>, <span class="number">2</span>, <span class="number">4</span>]));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">multi_prod</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>, <span class="number">2</span>, <span class="number">5</span>]));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">multi_prod</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>, <span class="number">3</span>, <span class="number">4</span>]));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">multi_prod</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>, <span class="number">3</span>, <span class="number">5</span>]));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">multi_prod</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">4</span>]));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">multi_prod</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">5</span>]));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">multi_prod</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">3</span>, <span class="number">4</span>]));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">multi_prod</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">3</span>, <span class="number">5</span>]));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">multi_prod</span>.<span class="ident">next</span>(), <span class="prelude-val">None</span>);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.Coalesce.html" title="struct itertools::structs::Coalesce">Coalesce</a>&lt;I, F&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.Coalesce.html" title="struct itertools::structs::Coalesce">Coalesce</a>&lt;I, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.Coalesce.html" title="struct itertools::structs::Coalesce">Coalesce</a>&lt;I, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>&gt;,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>;</span></code></div></div><h3 id='method.coalesce' class='method'><span id='coalesce.v' class='invisible'><code>fn <a href='#method.coalesce' class='fnname'>coalesce</a>&lt;F&gt;(self, f: F) -&gt; <a class="struct" href="../itertools/structs/struct.Coalesce.html" title="struct itertools::structs::Coalesce">Coalesce</a>&lt;Self, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightl
optionally merge together consecutive elements.</p>
<p>The closure <code>f</code> is passed two elements, <code>previous</code> and <code>current</code> and may
return either (1) <code>Ok(combined)</code> to merge the two values or
(2) <code>Err((previous', current'))</code> to indicate they can't be merged.
In (2), the value <code>previous'</code> is emitted by the iterator.
Either (1) <code>combined</code> or (2) <code>current'</code> becomes the previous value
when coalesce continues with the next pair of elements to merge. The
value that remains at the end is also emitted by the iterator.</p>
<p>Iterator element type is <code>Self::Item</code>.</p>
<p>This iterator is <em>fused</em>.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
<span class="comment">// sum same-sign runs together</span>
<span class="kw">let</span> <span class="ident">data</span> <span class="op">=</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="op">-</span><span class="number">3.</span>, <span class="number">3.</span>, <span class="number">1.</span>, <span class="number">0.</span>, <span class="op">-</span><span class="number">1.</span>];
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">data</span>.<span class="ident">into_iter</span>().<span class="ident">coalesce</span>(<span class="op">|</span><span class="ident">x</span>, <span class="ident">y</span><span class="op">|</span>
<span class="kw">if</span> (<span class="ident">x</span> <span class="op">&gt;=</span> <span class="number">0.</span>) <span class="op">==</span> (<span class="ident">y</span> <span class="op">&gt;=</span> <span class="number">0.</span>) {
<span class="prelude-val">Ok</span>(<span class="ident">x</span> <span class="op">+</span> <span class="ident">y</span>)
} <span class="kw">else</span> {
<span class="prelude-val">Err</span>((<span class="ident">x</span>, <span class="ident">y</span>))
}),
<span class="macro">vec</span><span class="macro">!</span>[<span class="op">-</span><span class="number">6.</span>, <span class="number">4.</span>, <span class="op">-</span><span class="number">1.</span>]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.Dedup.html" title="struct itertools::structs::Dedup">Dedup</a>&lt;I&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.Dedup.html" title="struct itertools::structs::Dedup">Dedup</a>&lt;I&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.Dedup.html" title="struct itertools::structs::Dedup">Dedup</a>&lt;I&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>;</span></code></div></div><h3 id='method.dedup' class='method'><span id='dedup.v' class='invisible'><code>fn <a href='#method.dedup' class='fnname'>dedup</a>(self) -&gt; <a class="struct" href="../itertools/structs/struct.Dedup.html" title="struct itertools::structs::Dedup">Dedup</a>&lt;Self&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Remove duplicates from sections of consecutive identical elements.
If the iterator is sorted, all elements will be unique.</p>
<p>Iterator element type is <code>Self::Item</code>.</p>
<p>This iterator is <em>fused</em>.</p>
<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">data</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1.</span>, <span class="number">1.</span>, <span class="number">2.</span>, <span class="number">3.</span>, <span class="number">3.</span>, <span class="number">2.</span>, <span class="number">2.</span>];
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">data</span>.<span class="ident">into_iter</span>().<span class="ident">dedup</span>(),
<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1.</span>, <span class="number">2.</span>, <span class="number">3.</span>, <span class="number">2.</span>]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.Unique.html" title="struct itertools::structs::Unique">Unique</a>&lt;I&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.Unique.html" title="struct itertools::structs::Unique">Unique</a>&lt;I&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.Unique.html" title="struct itertools::structs::Unique">Unique</a>&lt;I&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>;</span></code></div></div><h3 id='method.unique' class='method'><span id='unique.v' class='invisible'><code>fn <a href='#method.unique' class='fnname'>unique</a>(self) -&gt; <a class="struct" href="../itertools/structs/struct.Unique.html" title="struct itertools::structs::Unique">Unique</a>&lt;Self&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Return an iterator adaptor that filters out elements that have
already been produced once during the iteration. Duplicates
are detected using hash and equality.</p>
<p>Clones of visited elements are stored in a hash set in the
iterator.</p>
<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">data</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">10</span>, <span class="number">20</span>, <span class="number">30</span>, <span class="number">20</span>, <span class="number">40</span>, <span class="number">10</span>, <span class="number">50</span>];
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">data</span>.<span class="ident">into_iter</span>().<span class="ident">unique</span>(),
<span class="macro">vec</span><span class="macro">!</span>[<span class="number">10</span>, <span class="number">20</span>, <span class="number">30</span>, <span class="number">40</span>, <span class="number">50</span>]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.UniqueBy.html" title="struct itertools::structs::UniqueBy">UniqueBy</a>&lt;I, V, F&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.UniqueBy.html" title="struct itertools::structs::UniqueBy">UniqueBy</a>&lt;I, V, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, V, F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.UniqueBy.html" title="struct itertools::structs::UniqueBy">UniqueBy</a>&lt;I, V, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;V: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; V,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>;</span></code></div></div><h3 id='method.unique_by' class='method'><span id='unique_by.v' class='invisible'><code>fn <a href='#method.unique_by' class='fnname'>unique_by</a>&lt;V, F&gt;(self, f: F) -&gt; <a class="struct" href="../itertools/structs/struct.UniqueBy.html" title="struct itertools::structs::UniqueBy">UniqueBy</a>&lt;Self, V, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;V: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; V,&nbsp;</span></code></span></h3><div class='docblock'><p>Return an iterator adaptor that filters out elements that have
already been produced once during the iteration.</p>
<p>Duplicates are detected by comparing the key they map to
with the keying function <code>f</code> by hash and equality.
The keys are stored in a hash set in the iterator.</p>
<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">data</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;a&quot;</span>, <span class="string">&quot;bb&quot;</span>, <span class="string">&quot;aa&quot;</span>, <span class="string">&quot;c&quot;</span>, <span class="string">&quot;ccc&quot;</span>];
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">data</span>.<span class="ident">into_iter</span>().<span class="ident">unique_by</span>(<span class="op">|</span><span class="ident">s</span><span class="op">|</span> <span class="ident">s</span>.<span class="ident">len</span>()),
<span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;a&quot;</span>, <span class="string">&quot;bb&quot;</span>, <span class="string">&quot;ccc&quot;</span>]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.PeekingTakeWhile.html" title="struct itertools::structs::PeekingTakeWhile">PeekingTakeWhile</a>&lt;'a, I, F&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.PeekingTakeWhile.html" title="struct itertools::structs::PeekingTakeWhile">PeekingTakeWhile</a>&lt;'a, I, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a, I, F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.PeekingTakeWhile.html" title="struct itertools::structs::PeekingTakeWhile">PeekingTakeWhile</a>&lt;'a, I, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="../itertools/trait.PeekingNext.html" title="trait itertools::PeekingNext">PeekingNext</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>;</span></code></div></div><h3 id='method.peeking_take_while' class='method'><span id='peeking_take_while.v' class='invisible'><code>fn <a href='#method.peeking_take_while' class='fnname'>peeking_take_while</a>&lt;F&gt;(&amp;mut self, accept: F) -&gt; <a class="struct" href="../itertools/structs/struct.PeekingTakeWhile.html" title="struct itertools::structs::PeekingTakeWhile">PeekingTakeWhile</a>&lt;Self, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../itertools/trait.PeekingNext.html" title="trait itertools::PeekingNext">PeekingNext</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Return an iterator adaptor that borrows from this iterator and
takes items while the closure <code>accept</code> returns <code>true</code>.</p>
<p>This adaptor can only be used on iterators that implement <code>PeekingNext</code>
like <code>.peekable()</code>, <code>put_back</code> and a few other collection iterators.</p>
<p>The last and rejected element (first <code>false</code>) is still available when
<code>peeking_take_while</code> is done.</p>
<p>See also <a href="#method.take_while_ref"><code>.take_while_ref()</code></a>
which is a similar adaptor.</p>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.TakeWhileRef.html" title="struct itertools::structs::TakeWhileRef">TakeWhileRef</a>&lt;'a, I, F&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.TakeWhileRef.html" title="struct itertools::structs::TakeWhileRef">TakeWhileRef</a>&lt;'a, I, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;'a, I, F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.TakeWhileRef.html" title="struct itertools::structs::TakeWhileRef">TakeWhileRef</a>&lt;'a, I, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>;</span></code></div></div><h3 id='method.take_while_ref' class='method'><span id='take_while_ref.v' class='invisible'><code>fn <a href='#method.take_while_ref' class='fnname'>take_while_ref</a>&lt;F&gt;(&amp;mut self, accept: F) -&gt; <a class="struct" href="../itertools/structs/struct.TakeWhileRef.html" title="struct itertools::structs::TakeWhileRef">TakeWhileRef</a>&lt;Self, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Return an iterator adaptor that borrows from a <code>Clone</code>-able iterator
to only pick off elements while the predicate <code>accept</code> returns <code>true</code>.</p>
<p>It uses the <code>Clone</code> trait to restore the original iterator so that the
last and rejected element (first <code>false</code>) is still available when
<code>take_while_ref</code> is done.</p>
<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="kw-2">mut</span> <span class="ident">hexadecimals</span> <span class="op">=</span> <span class="string">&quot;0123456789abcdef&quot;</span>.<span class="ident">chars</span>();
<span class="kw">let</span> <span class="ident">decimals</span> <span class="op">=</span> <span class="ident">hexadecimals</span>.<span class="ident">take_while_ref</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span>.<span class="ident">is_numeric</span>())
.<span class="ident">collect</span>::<span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">decimals</span>, <span class="string">&quot;0123456789&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">hexadecimals</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="string">&#39;a&#39;</span>));
</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.WhileSome.html" title="struct itertools::structs::WhileSome">WhileSome</a>&lt;I&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.WhileSome.html" title="struct itertools::structs::WhileSome">WhileSome</a>&lt;I&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, A&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.WhileSome.html" title="struct itertools::structs::WhileSome">WhileSome</a>&lt;I&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;A&gt;&gt;,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = A;</span></code></div></div><h3 id='method.while_some' class='method'><span id='while_some.v' class='invisible'><code>fn <a href='#method.while_some' class='fnname'>while_some</a>&lt;A&gt;(self) -&gt; <a class="struct" href="../itertools/structs/struct.WhileSome.html" title="struct itertools::structs::WhileSome">WhileSome</a>&lt;Self&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;A&gt;&gt;,&nbsp;</span></code></span></h3><div class='docblock'><p>Return an iterator adaptor that filters <code>Option&lt;A&gt;</code> iterator elements
and produces <code>A</code>. Stops on the first <code>None</code> encountered.</p>
<p>Iterator element type is <code>A</code>, the unwrapped element.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
<span class="comment">// List all hexadecimal digits</span>
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(
(<span class="number">0</span>..).<span class="ident">map</span>(<span class="op">|</span><span class="ident">i</span><span class="op">|</span> <span class="ident">std</span>::<span class="ident">char</span>::<span class="ident">from_digit</span>(<span class="ident">i</span>, <span class="number">16</span>)).<span class="ident">while_some</span>(),
<span class="string">&quot;0123456789abcdef&quot;</span>.<span class="ident">chars</span>());
</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.TupleCombinations.html" title="struct itertools::structs::TupleCombinations">TupleCombinations</a>&lt;I, T&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.TupleCombinations.html" title="struct itertools::structs::TupleCombinations">TupleCombinations</a>&lt;I, T&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.TupleCombinations.html" title="struct itertools::structs::TupleCombinations">TupleCombinations</a>&lt;I, T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;T: HasCombination&lt;I&gt;,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = T;</span></code></div></div><h3 id='method.tuple_combinations' class='method'><span id='tuple_combinations.v' class='invisible'><code>fn <a href='#method.tuple_combinations' class='fnname'>tuple_combinations</a>&lt;T&gt;(self) -&gt; <a class="struct" href="../itertools/structs/struct.TupleCombinations.html" title="struct itertools::structs::TupleCombinations">TupleCombinations</a>&lt;Self, T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;T: HasCombination&lt;Self&gt;,&nbsp;</span></code></span></h3><div class='docblock'><p>Return an iterator adaptor that iterates over the combinations of the
elements from an iterator.</p>
<p>Iterator element can be any homogeneous tuple of type <code>Self::Item</code> with
size up to 4.</p>
<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="kw-2">mut</span> <span class="ident">v</span> <span class="op">=</span> <span class="ident">Vec</span>::<span class="ident">new</span>();
<span class="kw">for</span> (<span class="ident">a</span>, <span class="ident">b</span>) <span class="kw">in</span> (<span class="number">1</span>..<span class="number">5</span>).<span class="ident">tuple_combinations</span>() {
<span class="ident">v</span>.<span class="ident">push</span>((<span class="ident">a</span>, <span class="ident">b</span>));
}
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">v</span>, <span class="macro">vec</span><span class="macro">!</span>[(<span class="number">1</span>, <span class="number">2</span>), (<span class="number">1</span>, <span class="number">3</span>), (<span class="number">1</span>, <span class="number">4</span>), (<span class="number">2</span>, <span class="number">3</span>), (<span class="number">2</span>, <span class="number">4</span>), (<span class="number">3</span>, <span class="number">4</span>)]);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">it</span> <span class="op">=</span> (<span class="number">1</span>..<span class="number">5</span>).<span class="ident">tuple_combinations</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>((<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>)), <span class="ident">it</span>.<span class="ident">next</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>((<span class="number">1</span>, <span class="number">2</span>, <span class="number">4</span>)), <span class="ident">it</span>.<span class="ident">next</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>((<span class="number">1</span>, <span class="number">3</span>, <span class="number">4</span>)), <span class="ident">it</span>.<span class="ident">next</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>((<span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>)), <span class="ident">it</span>.<span class="ident">next</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">None</span>, <span class="ident">it</span>.<span class="ident">next</span>());
<span class="comment">// this requires a type hint</span>
<span class="kw">let</span> <span class="ident">it</span> <span class="op">=</span> (<span class="number">1</span>..<span class="number">5</span>).<span class="ident">tuple_combinations</span>::<span class="op">&lt;</span>(_, _, _)<span class="op">&gt;</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="number">2</span>, <span class="number">3</span>), (<span class="number">1</span>, <span class="number">2</span>, <span class="number">4</span>), (<span class="number">1</span>, <span class="number">3</span>, <span class="number">4</span>), (<span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>)]);
<span class="comment">// you can also specify the complete type</span>
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">TupleCombinations</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ops</span>::<span class="ident">Range</span>;
<span class="kw">let</span> <span class="ident">it</span>: <span class="ident">TupleCombinations</span><span class="op">&lt;</span><span class="ident">Range</span><span class="op">&lt;</span><span class="ident">u32</span><span class="op">&gt;</span>, (<span class="ident">u32</span>, <span class="ident">u32</span>, <span class="ident">u32</span>)<span class="op">&gt;</span> <span class="op">=</span> (<span class="number">1</span>..<span class="number">5</span>).<span class="ident">tuple_combinations</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="number">2</span>, <span class="number">3</span>), (<span class="number">1</span>, <span class="number">2</span>, <span class="number">4</span>), (<span class="number">1</span>, <span class="number">3</span>, <span class="number">4</span>), (<span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>)]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.Combinations.html" title="struct itertools::structs::Combinations">Combinations</a>&lt;I&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.Combinations.html" title="struct itertools::structs::Combinations">Combinations</a>&lt;I&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.Combinations.html" title="struct itertools::structs::Combinations">Combinations</a>&lt;I&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;;</span></code></div></div><h3 id='method.combinations' class='method'><span id='combinations.v' class='invisible'><code>fn <a href='#method.combinations' class='fnname'>combinations</a>(self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="struct" href="../itertools/structs/struct.Combinations.html" title="struct itertools::structs::Combinations">Combinations</a>&lt;Self&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Return an iterator adaptor that iterates over the <code>n</code>-length combinations of
the elements from an iterator.</p>
<p>Iterator element type is <code>Vec&lt;Self::Item&gt;</code>. The iterator produces a new Vec per iteration,
and clones the iterator elements.</p>
<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">5</span>).<span class="ident">combinations</span>(<span class="number">3</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="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>],
<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">4</span>],
<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">3</span>, <span class="number">4</span>],
<span class="macro">vec</span><span class="macro">!</span>[<span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>],
]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.PadUsing.html" title="struct itertools::structs::PadUsing">PadUsing</a>&lt;I, F&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.PadUsing.html" title="struct itertools::structs::PadUsing">PadUsing</a>&lt;I, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.PadUsing.html" title="struct itertools::structs::PadUsing">PadUsing</a>&lt;I, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>;</span></code></div></div><h3 id='method.pad_using' class='method'><span id='pad_using.v' class='invisible'><code>fn <a href='#method.pad_using' class='fnname'>pad_using</a>&lt;F&gt;(self, min: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, f: F) -&gt; <a class="struct" href="../itertools/structs/struct.PadUsing.html" title="struct itertools::structs::PadUsing">PadUsing</a>&lt;Self, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Return an iterator adaptor that pads the sequence to a minimum length of
<code>min</code> by filling missing elements using a closure <code>f</code>.</p>
<p>Iterator element type is <code>Self::Item</code>.</p>
<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">0</span>..<span class="number">5</span>).<span class="ident">pad_using</span>(<span class="number">10</span>, <span class="op">|</span><span class="ident">i</span><span class="op">|</span> <span class="number">2</span><span class="kw-2">*</span><span class="ident">i</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">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">10</span>, <span class="number">12</span>, <span class="number">14</span>, <span class="number">16</span>, <span class="number">18</span>]);
<span class="kw">let</span> <span class="ident">it</span> <span class="op">=</span> (<span class="number">0</span>..<span class="number">10</span>).<span class="ident">pad_using</span>(<span class="number">5</span>, <span class="op">|</span><span class="ident">i</span><span class="op">|</span> <span class="number">2</span><span class="kw-2">*</span><span class="ident">i</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">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>]);
<span class="kw">let</span> <span class="ident">it</span> <span class="op">=</span> (<span class="number">0</span>..<span class="number">5</span>).<span class="ident">pad_using</span>(<span class="number">10</span>, <span class="op">|</span><span class="ident">i</span><span class="op">|</span> <span class="number">2</span><span class="kw-2">*</span><span class="ident">i</span>).<span class="ident">rev</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">18</span>, <span class="number">16</span>, <span class="number">14</span>, <span class="number">12</span>, <span class="number">10</span>, <span class="number">4</span>, <span class="number">3</span>, <span class="number">2</span>, <span class="number">1</span>, <span class="number">0</span>]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.Flatten.html" title="struct itertools::structs::Flatten">Flatten</a>&lt;I, J&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.Flatten.html" title="struct itertools::structs::Flatten">Flatten</a>&lt;I, J&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, J&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.Flatten.html" title="struct itertools::structs::Flatten">Flatten</a>&lt;I, J&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&lt;IntoIter = J, Item = J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = J::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>;</span></code></div></div><h3 id='method.flatten' class='method'><span id='flatten.v' class='invisible'><code>fn <a href='#method.flatten' class='fnname'>flatten</a>(self) -&gt; <a class="struct" href="../itertools/structs/struct.Flatten.html" title="struct itertools::structs::Flatten">Flatten</a>&lt;Self, &lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.IntoIter" title="type core::iter::traits::IntoIterator::IntoIter">IntoIter</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Flatten an iterator of iterables into a single combined sequence of all
the elements in the iterables.</p>
<p>This is more or less equivalent to <code>.flat_map</code> with an identity
function.</p>
<p>See also the <a href="fn.flatten.html"><code>flatten</code></a> function.</p>
<div class='information'><div class='tooltip ignore'><span class='tooltiptext'>This example is not tested</span></div></div><pre class="rust rust-example-rendered ignore">
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
<span class="kw">let</span> <span class="ident">data</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>], <span class="macro">vec</span><span class="macro">!</span>[<span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>]];
<span class="kw">let</span> <span class="ident">flattened</span> <span class="op">=</span> <span class="ident">data</span>.<span class="ident">iter</span>().<span class="ident">flatten</span>();
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">flattened</span>, <span class="kw-2">&amp;</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.WithPosition.html" title="struct itertools::structs::WithPosition">WithPosition</a>&lt;I&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.WithPosition.html" title="struct itertools::structs::WithPosition">WithPosition</a>&lt;I&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.WithPosition.html" title="struct itertools::structs::WithPosition">WithPosition</a>&lt;I&gt;</span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="enum" href="../itertools/enum.Position.html" title="enum itertools::Position">Position</a>&lt;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt;;</span></code></div></div><h3 id='method.with_position' class='method'><span id='with_position.v' class='invisible'><code>fn <a href='#method.with_position' class='fnname'>with_position</a>(self) -&gt; <a class="struct" href="../itertools/structs/struct.WithPosition.html" title="struct itertools::structs::WithPosition">WithPosition</a>&lt;Self&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Return an iterator adaptor that wraps each element in a <code>Position</code> to
ease special-case handling of the first or last elements.</p>
<p>Iterator element type is
<a href="enum.Position.html"><code>Position&lt;Self::Item&gt;</code></a></p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">itertools</span>::{<span class="ident">Itertools</span>, <span class="ident">Position</span>};
<span class="kw">let</span> <span class="ident">it</span> <span class="op">=</span> (<span class="number">0</span>..<span class="number">4</span>).<span class="ident">with_position</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="ident">Position</span>::<span class="ident">First</span>(<span class="number">0</span>),
<span class="ident">Position</span>::<span class="ident">Middle</span>(<span class="number">1</span>),
<span class="ident">Position</span>::<span class="ident">Middle</span>(<span class="number">2</span>),
<span class="ident">Position</span>::<span class="ident">Last</span>(<span class="number">3</span>)]);
<span class="kw">let</span> <span class="ident">it</span> <span class="op">=</span> (<span class="number">0</span>..<span class="number">1</span>).<span class="ident">with_position</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="ident">Position</span>::<span class="ident">Only</span>(<span class="number">0</span>)]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.Positions.html" title="struct itertools::structs::Positions">Positions</a>&lt;I, F&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.Positions.html" title="struct itertools::structs::Positions">Positions</a>&lt;I, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.Positions.html" title="struct itertools::structs::Positions">Positions</a>&lt;I, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>,&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>;</span></code></div></div><h3 id='method.positions' class='method'><span id='positions.v' class='invisible'><code>fn <a href='#method.positions' class='fnname'>positions</a>&lt;P&gt;(self, predicate: P) -&gt; <a class="struct" href="../itertools/structs/struct.Positions.html" title="struct itertools::structs::Positions">Positions</a>&lt;Self, P&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Return an iterator adaptor that yields the indices of all elements
satisfying a predicate, counted from the start of the iterator.</p>
<p>Equivalent to <code>iter.enumerate().filter(|(_, v)| predicate(v)).map(|(i, _)| i)</code>.</p>
<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">data</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">9</span>];
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">data</span>.<span class="ident">iter</span>().<span class="ident">positions</span>(<span class="op">|</span><span class="ident">v</span><span class="op">|</span> <span class="ident">v</span> <span class="op">%</span> <span class="number">2</span> <span class="op">==</span> <span class="number">0</span>), <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">4</span>, <span class="number">5</span>]);
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">data</span>.<span class="ident">iter</span>().<span class="ident">positions</span>(<span class="op">|</span><span class="ident">v</span><span class="op">|</span> <span class="ident">v</span> <span class="op">%</span> <span class="number">2</span> <span class="op">==</span> <span class="number">1</span>).<span class="ident">rev</span>(), <span class="macro">vec</span><span class="macro">!</span>[<span class="number">7</span>, <span class="number">6</span>, <span class="number">3</span>, <span class="number">2</span>, <span class="number">0</span>]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="../itertools/structs/struct.Update.html" title="struct itertools::structs::Update">Update</a>&lt;I, F&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="../itertools/structs/struct.Update.html" title="struct itertools::structs::Update">Update</a>&lt;I, F&gt;</h3><code class="content"><span class="where fmt-newline">impl&lt;I, F&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a> for <a class="struct" href="../itertools/structs/struct.Update.html" title="struct itertools::structs::Update">Update</a>&lt;I, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;mut I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>),&nbsp;</span></span><span class="where fmt-newline"> type <a href='https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item' class="type">Item</a> = I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>;</span></code></div></div><h3 id='method.update' class='method'><span id='update.v' class='invisible'><code>fn <a href='#method.update' class='fnname'>update</a>&lt;F&gt;(self, updater: F) -&gt; <a class="struct" href="../itertools/structs/struct.Update.html" title="struct itertools::structs::Update">Update</a>&lt;Self, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;mut Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>),&nbsp;</span></code></span></h3><div class='docblock'><p>Return an iterator adaptor that applies a mutating function
to each element before yielding it.</p>
<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">input</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>], <span class="macro">vec</span><span class="macro">!</span>[<span class="number">3</span>, <span class="number">2</span>, <span class="number">1</span>]];
<span class="kw">let</span> <span class="ident">it</span> <span class="op">=</span> <span class="ident">input</span>.<span class="ident">into_iter</span>().<span class="ident">update</span>(<span class="op">|</span><span class="kw-2">mut</span> <span class="ident">v</span><span class="op">|</span> <span class="ident">v</span>.<span class="ident">push</span>(<span class="number">0</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="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">0</span>], <span class="macro">vec</span><span class="macro">!</span>[<span class="number">3</span>, <span class="number">2</span>, <span class="number">1</span>, <span class="number">0</span>]]);</pre>
</div><h3 id='method.next_tuple' class='method'><span id='next_tuple.v' class='invisible'><code>fn <a href='#method.next_tuple' class='fnname'>next_tuple</a>&lt;T&gt;(&amp;mut self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = T::Item&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;T: TupleCollect,&nbsp;</span></code></span></h3><div class='docblock'><p>Advances the iterator and returns the next items grouped in a tuple of
a specific size (up to 4).</p>
<p>If there are enough elements to be grouped in a tuple, then the tuple is
returned inside <code>Some</code>, otherwise <code>None</code> is returned.</p>
<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="kw-2">mut</span> <span class="ident">iter</span> <span class="op">=</span> <span class="number">1</span>..<span class="number">5</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>((<span class="number">1</span>, <span class="number">2</span>)), <span class="ident">iter</span>.<span class="ident">next_tuple</span>());</pre>
</div><h3 id='method.collect_tuple' class='method'><span id='collect_tuple.v' class='invisible'><code>fn <a href='#method.collect_tuple' class='fnname'>collect_tuple</a>&lt;T&gt;(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = T::Item&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;T: TupleCollect,&nbsp;</span></code></span></h3><div class='docblock'><p>Collects all items from the iterator into a tuple of a specific size
(up to 4).</p>
<p>If the number of elements inside the iterator is <strong>exactly</strong> equal to
the tuple size, then the tuple is returned inside <code>Some</code>, otherwise
<code>None</code> is returned.</p>
<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">iter</span> <span class="op">=</span> <span class="number">1</span>..<span class="number">3</span>;
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>((<span class="ident">x</span>, <span class="ident">y</span>)) <span class="op">=</span> <span class="ident">iter</span>.<span class="ident">collect_tuple</span>() {
<span class="macro">assert_eq</span><span class="macro">!</span>((<span class="ident">x</span>, <span class="ident">y</span>), (<span class="number">1</span>, <span class="number">2</span>))
} <span class="kw">else</span> {
<span class="macro">panic</span><span class="macro">!</span>(<span class="string">&quot;Expected two elements&quot;</span>)
}</pre>
</div><h3 id='method.find_position' class='method'><span id='find_position.v' class='invisible'><code>fn <a href='#method.find_position' class='fnname'>find_position</a>&lt;P&gt;(&amp;mut self, pred: P) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>, Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Find the position and value of the first element satisfying a predicate.</p>
<p>The iterator is not advanced past the first element found.</p>
<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">text</span> <span class="op">=</span> <span class="string">&quot;Hα&quot;</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">text</span>.<span class="ident">chars</span>().<span class="ident">find_position</span>(<span class="op">|</span><span class="ident">ch</span><span class="op">|</span> <span class="ident">ch</span>.<span class="ident">is_lowercase</span>()), <span class="prelude-val">Some</span>((<span class="number">1</span>, <span class="string">&#39;α&#39;</span>)));</pre>
</div><h3 id='method.all_equal' class='method'><span id='all_equal.v' class='invisible'><code>fn <a href='#method.all_equal' class='fnname'>all_equal</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Check whether all elements compare equal.</p>
<p>Empty iterators are considered to have equal elements:</p>
<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">data</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">3</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">5</span>];
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">data</span>.<span class="ident">iter</span>().<span class="ident">all_equal</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">data</span>[<span class="number">0</span>..<span class="number">3</span>].<span class="ident">iter</span>().<span class="ident">all_equal</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">data</span>[<span class="number">3</span>..<span class="number">5</span>].<span class="ident">iter</span>().<span class="ident">all_equal</span>());
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">data</span>[<span class="number">5</span>..<span class="number">8</span>].<span class="ident">iter</span>().<span class="ident">all_equal</span>());
<span class="kw">let</span> <span class="ident">data</span> : <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">usize</span><span class="op">&gt;</span> <span class="op">=</span> <span class="prelude-val">None</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">data</span>.<span class="ident">into_iter</span>().<span class="ident">all_equal</span>());</pre>
</div><h3 id='method.dropping' class='method'><span id='dropping.v' class='invisible'><code>fn <a href='#method.dropping' class='fnname'>dropping</a>(self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; Self <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Consume the first <code>n</code> elements from the iterator eagerly,
and return the same iterator again.</p>
<p>It works similarly to <em>.skip(</em> <code>n</code> <em>)</em> except it is eager and
preserves the iterator type.</p>
<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="kw-2">mut</span> <span class="ident">iter</span> <span class="op">=</span> <span class="string">&quot;αβγ&quot;</span>.<span class="ident">chars</span>().<span class="ident">dropping</span>(<span class="number">2</span>);
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">iter</span>, <span class="string">&quot;γ&quot;</span>.<span class="ident">chars</span>());</pre>
<p><em>Fusing notes: if the iterator is exhausted by dropping,
the result of calling <code>.next()</code> again depends on the iterator implementation.</em></p>
</div><h3 id='method.dropping_back' class='method'><span id='dropping_back.v' class='invisible'><code>fn <a href='#method.dropping_back' class='fnname'>dropping_back</a>(self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; Self <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.DoubleEndedIterator.html" title="trait core::iter::traits::DoubleEndedIterator">DoubleEndedIterator</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Consume the last <code>n</code> elements from the iterator eagerly,
and return the same iterator again.</p>
<p>This is only possible on double ended iterators. <code>n</code> may be
larger than the number of elements.</p>
<p>Note: This method is eager, dropping the back elements immediately and
preserves the iterator type.</p>
<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">init</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>, <span class="number">3</span>, <span class="number">6</span>, <span class="number">9</span>].<span class="ident">into_iter</span>().<span class="ident">dropping_back</span>(<span class="number">1</span>);
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">init</span>, <span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>, <span class="number">3</span>, <span class="number">6</span>]);</pre>
</div><h3 id='method.foreach' class='method'><span id='foreach.v' class='invisible'><code>fn <a href='#method.foreach' class='fnname'>foreach</a>&lt;F&gt;(self, f: F) <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>),<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Run the closure <code>f</code> eagerly on each element of the iterator.</p>
<p>Consumes the iterator until its end.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">sync</span>::<span class="ident">mpsc</span>::<span class="ident">channel</span>;
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
<span class="kw">let</span> (<span class="ident">tx</span>, <span class="ident">rx</span>) <span class="op">=</span> <span class="ident">channel</span>();
<span class="comment">// use .foreach() to apply a function to each value -- sending it</span>
(<span class="number">0</span>..<span class="number">5</span>).<span class="ident">map</span>(<span class="op">|</span><span class="ident">x</span><span class="op">|</span> <span class="ident">x</span> <span class="op">*</span> <span class="number">2</span> <span class="op">+</span> <span class="number">1</span>).<span class="ident">foreach</span>(<span class="op">|</span><span class="ident">x</span><span class="op">|</span> { <span class="ident">tx</span>.<span class="ident">send</span>(<span class="ident">x</span>).<span class="ident">unwrap</span>(); } );
<span class="ident">drop</span>(<span class="ident">tx</span>);
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">rx</span>.<span class="ident">iter</span>(), <span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">9</span>]);</pre>
</div><h3 id='method.concat' class='method'><span id='concat.v' class='invisible'><code>fn <a href='#method.concat' class='fnname'>concat</a>(self) -&gt; Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.Extend.html" title="trait core::iter::traits::Extend">Extend</a>&lt;&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a> as <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html#associatedtype.Item" title="type core::iter::traits::IntoIterator::Item">Item</a>&gt; + <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Combine all an iterator's elements into one element by using <code>Extend</code>.</p>
<p>This combinator will extend the first item with each of the rest of the
items of the iterator. If the iterator is empty, the default value of
<code>I::Item</code> is returned.</p>
<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">input</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>], <span class="macro">vec</span><span class="macro">!</span>[<span class="number">2</span>, <span class="number">3</span>], <span class="macro">vec</span><span class="macro">!</span>[<span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>]];
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">input</span>.<span class="ident">into_iter</span>().<span class="ident">concat</span>(),
<span class="macro">vec</span><span class="macro">!</span>[<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</h3><code class="content"><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</span></code></div></div><h3 id='method.collect_vec' class='method'><span id='collect_vec.v' class='invisible'><code>fn <a href='#method.collect_vec' class='fnname'>collect_vec</a>(self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code></span></h3><div class='docblock'><p><code>.collect_vec()</code> is simply a type specialization of <code>.collect()</code>,
for convenience.</p>
</div><h3 id='method.set_from' class='method'><span id='set_from.v' class='invisible'><code>fn <a href='#method.set_from' class='fnname'>set_from</a>&lt;'a, A:&nbsp;'a, J&gt;(&amp;mut self, from: J) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;'a mut </a>A&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;J: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html" title="trait core::iter::traits::IntoIterator">IntoIterator</a>&lt;Item = A&gt;,&nbsp;</span></code></span></h3><div class='docblock'><p>Assign to each reference in <code>self</code> from the <code>from</code> iterator,
stopping at the shortest of the two iterators.</p>
<p>The <code>from</code> iterator is queried for its next element before the <code>self</code>
iterator, and if either is exhausted the method is done.</p>
<p>Return the number of elements written.</p>
<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="kw-2">mut</span> <span class="ident">xs</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">xs</span>.<span class="ident">iter_mut</span>().<span class="ident">set_from</span>(<span class="number">1</span>..);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">xs</span>, [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>]);</pre>
</div><h3 id='method.join' class='method'><span id='join.v' class='invisible'><code>fn <a href='#method.join' class='fnname'>join</a>(&amp;mut self, sep: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Combine all iterator elements into one String, seperated by <code>sep</code>.</p>
<p>Use the <code>Display</code> implementation of each element.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>([<span class="string">&quot;a&quot;</span>, <span class="string">&quot;b&quot;</span>, <span class="string">&quot;c&quot;</span>].<span class="ident">iter</span>().<span class="ident">join</span>(<span class="string">&quot;, &quot;</span>), <span class="string">&quot;a, b, c&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>([<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].<span class="ident">iter</span>().<span class="ident">join</span>(<span class="string">&quot;, &quot;</span>), <span class="string">&quot;1, 2, 3&quot;</span>);</pre>
</div><h3 id='method.format' class='method'><span id='format.v' class='invisible'><code>fn <a href='#method.format' class='fnname'>format</a>(self, sep: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="struct" href="../itertools/structs/struct.Format.html" title="struct itertools::structs::Format">Format</a>&lt;Self&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Format all iterator elements, separated by <code>sep</code>.</p>
<p>All elements are formatted (any formatting trait)
with <code>sep</code> inserted between each element.</p>
<p><strong>Panics</strong> if the formatter helper is formatted more than once.</p>
<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">data</span> <span class="op">=</span> [<span class="number">1.1</span>, <span class="number">2.71828</span>, <span class="op">-</span><span class="number">3.</span>];
<span class="macro">assert_eq</span><span class="macro">!</span>(
<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{:.2}&quot;</span>, <span class="ident">data</span>.<span class="ident">iter</span>().<span class="ident">format</span>(<span class="string">&quot;, &quot;</span>)),
<span class="string">&quot;1.10, 2.72, -3.00&quot;</span>);</pre>
</div><h3 id='method.format_with' class='method'><span id='format_with.v' class='invisible'><code>fn <a href='#method.format_with' class='fnname'>format_with</a>&lt;F&gt;(self, sep: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, format: F) -&gt; <a class="struct" href="../itertools/structs/struct.FormatWith.html" title="struct itertools::structs::FormatWith">FormatWith</a>&lt;Self, F&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, &amp;mut <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Format all iterator elements, separated by <code>sep</code>.</p>
<p>This is a customizable version of <code>.format()</code>.</p>
<p>The supplied closure <code>format</code> is called once per iterator element,
with two arguments: the element and a callback that takes a
<code>&amp;Display</code> value, i.e. any reference to type that implements <code>Display</code>.</p>
<p>Using <code>&amp;format_args!(...)</code> is the most versatile way to apply custom
element formatting. The callback can be called multiple times if needed.</p>
<p><strong>Panics</strong> if the formatter helper is formatted more than once.</p>
<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">data</span> <span class="op">=</span> [<span class="number">1.1</span>, <span class="number">2.71828</span>, <span class="op">-</span><span class="number">3.</span>];
<span class="kw">let</span> <span class="ident">data_formatter</span> <span class="op">=</span> <span class="ident">data</span>.<span class="ident">iter</span>().<span class="ident">format_with</span>(<span class="string">&quot;, &quot;</span>, <span class="op">|</span><span class="ident">elt</span>, <span class="ident">f</span><span class="op">|</span> <span class="ident">f</span>(<span class="kw-2">&amp;</span><span class="macro">format_args</span><span class="macro">!</span>(<span class="string">&quot;{:.2}&quot;</span>, <span class="ident">elt</span>)));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">data_formatter</span>),
<span class="string">&quot;1.10, 2.72, -3.00&quot;</span>);
<span class="comment">// .format_with() is recursively composable</span>
<span class="kw">let</span> <span class="ident">matrix</span> <span class="op">=</span> [[<span class="number">1.</span>, <span class="number">2.</span>, <span class="number">3.</span>],
[<span class="number">4.</span>, <span class="number">5.</span>, <span class="number">6.</span>]];
<span class="kw">let</span> <span class="ident">matrix_formatter</span> <span class="op">=</span> <span class="ident">matrix</span>.<span class="ident">iter</span>().<span class="ident">format_with</span>(<span class="string">&quot;\n&quot;</span>, <span class="op">|</span><span class="ident">row</span>, <span class="ident">f</span><span class="op">|</span> {
<span class="ident">f</span>(<span class="kw-2">&amp;</span><span class="ident">row</span>.<span class="ident">iter</span>().<span class="ident">format_with</span>(<span class="string">&quot;, &quot;</span>, <span class="op">|</span><span class="ident">elt</span>, <span class="ident">g</span><span class="op">|</span> <span class="ident">g</span>(<span class="kw-2">&amp;</span><span class="ident">elt</span>)))
});
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;{}&quot;</span>, <span class="ident">matrix_formatter</span>),
<span class="string">&quot;1, 2, 3\n4, 5, 6&quot;</span>);
</pre>
</div><h3 id='method.fold_results' class='method'><span id='fold_results.v' class='invisible'><code>fn <a href='#method.fold_results' class='fnname'>fold_results</a>&lt;A, E, B, F&gt;(&amp;mut self, start: B, f: F) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;B, E&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;A, E&gt;&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(B, A) -&gt; B,&nbsp;</span></code></span></h3><div class='docblock'><p>Fold <code>Result</code> values from an iterator.</p>
<p>Only <code>Ok</code> values are folded. If no error is encountered, the folded
value is returned inside <code>Ok</code>. Otherwise, the operation terminates
and returns the first <code>Err</code> value it encounters. No iterator elements are
consumed after the first error.</p>
<p>The first accumulator value is the <code>start</code> parameter.
Each iteration passes the accumulator value and the next value inside <code>Ok</code>
to the fold function <code>f</code> and its return value becomes the new accumulator value.</p>
<p>For example the sequence <em>Ok(1), Ok(2), Ok(3)</em> will result in a
computation like this:</p>
<div class='information'><div class='tooltip ignore'><span class='tooltiptext'>This example is not tested</span></div></div><pre class="rust rust-example-rendered ignore">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">accum</span> <span class="op">=</span> <span class="ident">start</span>;
<span class="ident">accum</span> <span class="op">=</span> <span class="ident">f</span>(<span class="ident">accum</span>, <span class="number">1</span>);
<span class="ident">accum</span> <span class="op">=</span> <span class="ident">f</span>(<span class="ident">accum</span>, <span class="number">2</span>);
<span class="ident">accum</span> <span class="op">=</span> <span class="ident">f</span>(<span class="ident">accum</span>, <span class="number">3</span>);</pre>
<p>With a <code>start</code> value of 0 and an addition as folding function,
this effetively results in <em>((0 + 1) + 2) + 3</em></p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ops</span>::<span class="ident">Add</span>;
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
<span class="kw">let</span> <span class="ident">values</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="op">-</span><span class="number">2</span>, <span class="op">-</span><span class="number">1</span>, <span class="number">2</span>, <span class="number">1</span>];
<span class="macro">assert_eq</span><span class="macro">!</span>(
<span class="ident">values</span>.<span class="ident">iter</span>()
.<span class="ident">map</span>(<span class="prelude-val">Ok</span>::<span class="op">&lt;</span>_, ()<span class="op">&gt;</span>)
.<span class="ident">fold_results</span>(<span class="number">0</span>, <span class="ident">Add</span>::<span class="ident">add</span>),
<span class="prelude-val">Ok</span>(<span class="number">3</span>)
);
<span class="macro">assert</span><span class="macro">!</span>(
<span class="ident">values</span>.<span class="ident">iter</span>()
.<span class="ident">map</span>(<span class="op">|</span><span class="kw-2">&amp;</span><span class="ident">x</span><span class="op">|</span> <span class="kw">if</span> <span class="ident">x</span> <span class="op">&gt;=</span> <span class="number">0</span> { <span class="prelude-val">Ok</span>(<span class="ident">x</span>) } <span class="kw">else</span> { <span class="prelude-val">Err</span>(<span class="string">&quot;Negative number&quot;</span>) })
.<span class="ident">fold_results</span>(<span class="number">0</span>, <span class="ident">Add</span>::<span class="ident">add</span>)
.<span class="ident">is_err</span>()
);</pre>
</div><h3 id='method.fold_options' class='method'><span id='fold_options.v' class='invisible'><code>fn <a href='#method.fold_options' class='fnname'>fold_options</a>&lt;A, B, F&gt;(&amp;mut self, start: B, f: F) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;B&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;A&gt;&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(B, A) -&gt; B,&nbsp;</span></code></span></h3><div class='docblock'><p>Fold <code>Option</code> values from an iterator.</p>
<p>Only <code>Some</code> values are folded. If no <code>None</code> is encountered, the folded
value is returned inside <code>Some</code>. Otherwise, the operation terminates
and returns <code>None</code>. No iterator elements are consumed after the <code>None</code>.</p>
<p>This is the <code>Option</code> equivalent to <code>fold_results</code>.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ops</span>::<span class="ident">Add</span>;
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">values</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="prelude-val">Some</span>(<span class="number">1</span>), <span class="prelude-val">Some</span>(<span class="number">2</span>), <span class="prelude-val">Some</span>(<span class="op">-</span><span class="number">2</span>)].<span class="ident">into_iter</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">values</span>.<span class="ident">fold_options</span>(<span class="number">5</span>, <span class="ident">Add</span>::<span class="ident">add</span>), <span class="prelude-val">Some</span>(<span class="number">5</span> <span class="op">+</span> <span class="number">1</span> <span class="op">+</span> <span class="number">2</span> <span class="op">-</span> <span class="number">2</span>));
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">more_values</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="prelude-val">Some</span>(<span class="number">2</span>), <span class="prelude-val">None</span>, <span class="prelude-val">Some</span>(<span class="number">0</span>)].<span class="ident">into_iter</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">more_values</span>.<span class="ident">fold_options</span>(<span class="number">0</span>, <span class="ident">Add</span>::<span class="ident">add</span>).<span class="ident">is_none</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">more_values</span>.<span class="ident">next</span>().<span class="ident">unwrap</span>(), <span class="prelude-val">Some</span>(<span class="number">0</span>));</pre>
</div><h3 id='method.fold1' class='method'><span id='fold1.v' class='invisible'><code>fn <a href='#method.fold1' class='fnname'>fold1</a>&lt;F&gt;(self, f: F) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Accumulator of the elements in the iterator.</p>
<p>Like <code>.fold()</code>, without a base case. If the iterator is
empty, return <code>None</code>. With just one element, return it.
Otherwise elements are accumulated in sequence using the closure <code>f</code>.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>((<span class="number">0</span>..<span class="number">10</span>).<span class="ident">fold1</span>(<span class="op">|</span><span class="ident">x</span>, <span class="ident">y</span><span class="op">|</span> <span class="ident">x</span> <span class="op">+</span> <span class="ident">y</span>).<span class="ident">unwrap_or</span>(<span class="number">0</span>), <span class="number">45</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>((<span class="number">0</span>..<span class="number">0</span>).<span class="ident">fold1</span>(<span class="op">|</span><span class="ident">x</span>, <span class="ident">y</span><span class="op">|</span> <span class="ident">x</span> <span class="op">*</span> <span class="ident">y</span>), <span class="prelude-val">None</span>);</pre>
</div><h3 id='method.tree_fold1' class='method'><span id='tree_fold1.v' class='invisible'><code>fn <a href='#method.tree_fold1' class='fnname'>tree_fold1</a>&lt;F&gt;(self, f: F) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Accumulate the elements in the iterator in a tree-like manner.</p>
<p>You can think of it as, while there's more than one item, repeatedly
combining adjacent items. It does so in bottom-up-merge-sort order,
however, so that it needs only logarithmic stack space.</p>
<p>This produces a call tree like the following (where the calls under
an item are done after reading that item):</p>
<pre><code class="language-text">1 2 3 4 5 6 7
│ │ │ │ │ │ │
└─f └─f └─f │
│ │ │ │
└───f └─f
│ │
└─────f
</code></pre>
<p>Which, for non-associative functions, will typically produce a different
result than the linear call tree used by <code>fold1</code>:</p>
<pre><code class="language-text">1 2 3 4 5 6 7
│ │ │ │ │ │ │
└─f─f─f─f─f─f
</code></pre>
<p>If <code>f</code> is associative, prefer the normal <code>fold1</code> instead.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
<span class="comment">// The same tree as above</span>
<span class="kw">let</span> <span class="ident">num_strings</span> <span class="op">=</span> (<span class="number">1</span>..<span class="number">8</span>).<span class="ident">map</span>(<span class="op">|</span><span class="ident">x</span><span class="op">|</span> <span class="ident">x</span>.<span class="ident">to_string</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">num_strings</span>.<span class="ident">tree_fold1</span>(<span class="op">|</span><span class="ident">x</span>, <span class="ident">y</span><span class="op">|</span> <span class="macro">format</span><span class="macro">!</span>(<span class="string">&quot;f({}, {})&quot;</span>, <span class="ident">x</span>, <span class="ident">y</span>)),
<span class="prelude-val">Some</span>(<span class="ident">String</span>::<span class="ident">from</span>(<span class="string">&quot;f(f(f(1, 2), f(3, 4)), f(f(5, 6), 7))&quot;</span>)));
<span class="comment">// Like fold1, an empty iterator produces None</span>
<span class="macro">assert_eq</span><span class="macro">!</span>((<span class="number">0</span>..<span class="number">0</span>).<span class="ident">tree_fold1</span>(<span class="op">|</span><span class="ident">x</span>, <span class="ident">y</span><span class="op">|</span> <span class="ident">x</span> <span class="op">*</span> <span class="ident">y</span>), <span class="prelude-val">None</span>);
<span class="comment">// tree_fold1 matches fold1 for associative operations...</span>
<span class="macro">assert_eq</span><span class="macro">!</span>((<span class="number">0</span>..<span class="number">10</span>).<span class="ident">tree_fold1</span>(<span class="op">|</span><span class="ident">x</span>, <span class="ident">y</span><span class="op">|</span> <span class="ident">x</span> <span class="op">+</span> <span class="ident">y</span>),
(<span class="number">0</span>..<span class="number">10</span>).<span class="ident">fold1</span>(<span class="op">|</span><span class="ident">x</span>, <span class="ident">y</span><span class="op">|</span> <span class="ident">x</span> <span class="op">+</span> <span class="ident">y</span>));
<span class="comment">// ...but not for non-associative ones</span>
<span class="macro">assert</span><span class="macro">!</span>((<span class="number">0</span>..<span class="number">10</span>).<span class="ident">tree_fold1</span>(<span class="op">|</span><span class="ident">x</span>, <span class="ident">y</span><span class="op">|</span> <span class="ident">x</span> <span class="op">-</span> <span class="ident">y</span>)
<span class="op">!=</span> (<span class="number">0</span>..<span class="number">10</span>).<span class="ident">fold1</span>(<span class="op">|</span><span class="ident">x</span>, <span class="ident">y</span><span class="op">|</span> <span class="ident">x</span> <span class="op">-</span> <span class="ident">y</span>));</pre>
</div><h3 id='method.fold_while' class='method'><span id='fold_while.v' class='invisible'><code>fn <a href='#method.fold_while' class='fnname'>fold_while</a>&lt;B, F&gt;(&amp;mut self, init: B, f: F) -&gt; <a class="enum" href="../itertools/enum.FoldWhile.html" title="enum itertools::FoldWhile">FoldWhile</a>&lt;B&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(B, Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="enum" href="../itertools/enum.FoldWhile.html" title="enum itertools::FoldWhile">FoldWhile</a>&lt;B&gt;,&nbsp;</span></code></span></h3><div class='docblock'><p>An iterator method that applies a function, producing a single, final value.</p>
<p><code>fold_while()</code> is basically equivalent to <code>fold()</code> but with additional support for
early exit via short-circuiting.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">FoldWhile</span>::{<span class="ident">Continue</span>, <span class="ident">Done</span>};
<span class="kw">let</span> <span class="ident">numbers</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>, <span class="number">10</span>];
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">result</span> <span class="op">=</span> <span class="number">0</span>;
<span class="comment">// for loop:</span>
<span class="kw">for</span> <span class="ident">i</span> <span class="kw">in</span> <span class="kw-2">&amp;</span><span class="ident">numbers</span> {
<span class="kw">if</span> <span class="kw-2">*</span><span class="ident">i</span> <span class="op">&gt;</span> <span class="number">5</span> {
<span class="kw">break</span>;
}
<span class="ident">result</span> <span class="op">=</span> <span class="ident">result</span> <span class="op">+</span> <span class="ident">i</span>;
}
<span class="comment">// fold:</span>
<span class="kw">let</span> <span class="ident">result2</span> <span class="op">=</span> <span class="ident">numbers</span>.<span class="ident">iter</span>().<span class="ident">fold</span>(<span class="number">0</span>, <span class="op">|</span><span class="ident">acc</span>, <span class="ident">x</span><span class="op">|</span> {
<span class="kw">if</span> <span class="kw-2">*</span><span class="ident">x</span> <span class="op">&gt;</span> <span class="number">5</span> { <span class="ident">acc</span> } <span class="kw">else</span> { <span class="ident">acc</span> <span class="op">+</span> <span class="ident">x</span> }
});
<span class="comment">// fold_while:</span>
<span class="kw">let</span> <span class="ident">result3</span> <span class="op">=</span> <span class="ident">numbers</span>.<span class="ident">iter</span>().<span class="ident">fold_while</span>(<span class="number">0</span>, <span class="op">|</span><span class="ident">acc</span>, <span class="ident">x</span><span class="op">|</span> {
<span class="kw">if</span> <span class="kw-2">*</span><span class="ident">x</span> <span class="op">&gt;</span> <span class="number">5</span> { <span class="ident">Done</span>(<span class="ident">acc</span>) } <span class="kw">else</span> { <span class="ident">Continue</span>(<span class="ident">acc</span> <span class="op">+</span> <span class="ident">x</span>) }
}).<span class="ident">into_inner</span>();
<span class="comment">// they&#39;re the same</span>
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">result</span>, <span class="ident">result2</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">result2</span>, <span class="ident">result3</span>);</pre>
<p>The big difference between the computations of <code>result2</code> and <code>result3</code> is that while
<code>fold()</code> called the provided closure for every item of the callee iterator,
<code>fold_while()</code> actually stopped iterating as soon as it encountered <code>Fold::Done(_)</code>.</p>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</h3><code class="content"><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</span></code></div></div><h3 id='method.sorted' class='method'><span id='sorted.v' class='invisible'><code>fn <a href='#method.sorted' class='fnname'>sorted</a>(self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Collect all iterator elements into a sorted vector in ascending order.</p>
<p><strong>Note:</strong> This consumes the entire iterator, uses the
<code>slice::sort_by()</code> method and returns the sorted vector.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
<span class="comment">// sort the letters of the text in ascending order</span>
<span class="kw">let</span> <span class="ident">text</span> <span class="op">=</span> <span class="string">&quot;bdacfe&quot;</span>;
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">text</span>.<span class="ident">chars</span>().<span class="ident">sorted</span>(),
<span class="string">&quot;abcdef&quot;</span>.<span class="ident">chars</span>());</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</h3><code class="content"><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</span></code></div></div><h3 id='method.sorted_by' class='method'><span id='sorted_by.v' class='invisible'><code>fn <a href='#method.sorted_by' class='fnname'>sorted_by</a>&lt;F&gt;(self, cmp: F) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, &amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Collect all iterator elements into a sorted vector.</p>
<p><strong>Note:</strong> This consumes the entire iterator, uses the
<code>slice::sort_by()</code> method and returns the sorted vector.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
<span class="comment">// sort people in descending order by age</span>
<span class="kw">let</span> <span class="ident">people</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[(<span class="string">&quot;Jane&quot;</span>, <span class="number">20</span>), (<span class="string">&quot;John&quot;</span>, <span class="number">18</span>), (<span class="string">&quot;Jill&quot;</span>, <span class="number">30</span>), (<span class="string">&quot;Jack&quot;</span>, <span class="number">27</span>)];
<span class="kw">let</span> <span class="ident">oldest_people_first</span> <span class="op">=</span> <span class="ident">people</span>
.<span class="ident">into_iter</span>()
.<span class="ident">sorted_by</span>(<span class="op">|</span><span class="ident">a</span>, <span class="ident">b</span><span class="op">|</span> <span class="ident">Ord</span>::<span class="ident">cmp</span>(<span class="kw-2">&amp;</span><span class="ident">b</span>.<span class="number">1</span>, <span class="kw-2">&amp;</span><span class="ident">a</span>.<span class="number">1</span>))
.<span class="ident">into_iter</span>()
.<span class="ident">map</span>(<span class="op">|</span>(<span class="ident">person</span>, <span class="ident">_age</span>)<span class="op">|</span> <span class="ident">person</span>);
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">oldest_people_first</span>,
<span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;Jill&quot;</span>, <span class="string">&quot;Jack&quot;</span>, <span class="string">&quot;Jane&quot;</span>, <span class="string">&quot;John&quot;</span>]);</pre>
</div><div class="important-traits"><div class='tooltip'><span class='tooltiptext'>Important traits for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</span></div><div class="content hidden"><h3 class="important">Important traits for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</h3><code class="content"><span class="where fmt-newline">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>&gt;</span></code></div></div><h3 id='method.sorted_by_key' class='method'><span id='sorted_by_key.v' class='invisible'><code>fn <a href='#method.sorted_by_key' class='fnname'>sorted_by_key</a>&lt;K, F&gt;(self, f: F) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; K,&nbsp;</span></code></span></h3><div class='docblock'><p>Collect all iterator elements into a sorted vector.</p>
<p><strong>Note:</strong> This consumes the entire iterator, uses the
<code>slice::sort_by_key()</code> method and returns the sorted vector.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
<span class="comment">// sort people in descending order by age</span>
<span class="kw">let</span> <span class="ident">people</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[(<span class="string">&quot;Jane&quot;</span>, <span class="number">20</span>), (<span class="string">&quot;John&quot;</span>, <span class="number">18</span>), (<span class="string">&quot;Jill&quot;</span>, <span class="number">30</span>), (<span class="string">&quot;Jack&quot;</span>, <span class="number">27</span>)];
<span class="kw">let</span> <span class="ident">oldest_people_first</span> <span class="op">=</span> <span class="ident">people</span>
.<span class="ident">into_iter</span>()
.<span class="ident">sorted_by_key</span>(<span class="op">|</span><span class="ident">x</span><span class="op">|</span> <span class="op">-</span><span class="ident">x</span>.<span class="number">1</span>)
.<span class="ident">into_iter</span>()
.<span class="ident">map</span>(<span class="op">|</span>(<span class="ident">person</span>, <span class="ident">_age</span>)<span class="op">|</span> <span class="ident">person</span>);
<span class="ident">itertools</span>::<span class="ident">assert_equal</span>(<span class="ident">oldest_people_first</span>,
<span class="macro">vec</span><span class="macro">!</span>[<span class="string">&quot;Jill&quot;</span>, <span class="string">&quot;Jack&quot;</span>, <span class="string">&quot;Jane&quot;</span>, <span class="string">&quot;John&quot;</span>]);</pre>
</div><h3 id='method.partition_map' class='method'><span id='partition_map.v' class='invisible'><code>fn <a href='#method.partition_map' class='fnname'>partition_map</a>&lt;A, B, F, L, R&gt;(self, predicate: F) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>A, B<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a> <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>(Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="enum" href="../itertools/enum.Either.html" title="enum itertools::Either">Either</a>&lt;L, R&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;A: <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.Extend.html" title="trait core::iter::traits::Extend">Extend</a>&lt;L&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;B: <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/trait.Extend.html" title="trait core::iter::traits::Extend">Extend</a>&lt;R&gt;,&nbsp;</span></code></span></h3><div class='docblock'><p>Collect all iterator elements into one of two
partitions. Unlike <code>Iterator::partition</code>, each partition may
have a distinct type.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">itertools</span>::{<span class="ident">Itertools</span>, <span class="ident">Either</span>};
<span class="kw">let</span> <span class="ident">successes_and_failures</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="prelude-val">Ok</span>(<span class="number">1</span>), <span class="prelude-val">Err</span>(<span class="bool-val">false</span>), <span class="prelude-val">Err</span>(<span class="bool-val">true</span>), <span class="prelude-val">Ok</span>(<span class="number">2</span>)];
<span class="kw">let</span> (<span class="ident">successes</span>, <span class="ident">failures</span>): (<span class="ident">Vec</span><span class="op">&lt;</span>_<span class="op">&gt;</span>, <span class="ident">Vec</span><span class="op">&lt;</span>_<span class="op">&gt;</span>) <span class="op">=</span> <span class="ident">successes_and_failures</span>
.<span class="ident">into_iter</span>()
.<span class="ident">partition_map</span>(<span class="op">|</span><span class="ident">r</span><span class="op">|</span> {
<span class="kw">match</span> <span class="ident">r</span> {
<span class="prelude-val">Ok</span>(<span class="ident">v</span>) <span class="op">=&gt;</span> <span class="ident">Either</span>::<span class="ident">Left</span>(<span class="ident">v</span>),
<span class="prelude-val">Err</span>(<span class="ident">v</span>) <span class="op">=&gt;</span> <span class="ident">Either</span>::<span class="ident">Right</span>(<span class="ident">v</span>),
}
});
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">successes</span>, [<span class="number">1</span>, <span class="number">2</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">failures</span>, [<span class="bool-val">false</span>, <span class="bool-val">true</span>]);</pre>
</div><h3 id='method.into_group_map' class='method'><span id='into_group_map.v' class='invisible'><code>fn <a href='#method.into_group_map' class='fnname'>into_group_map</a>&lt;K, V&gt;(self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/std/collections/hash/map/struct.HashMap.html" title="struct std::collections::hash::map::HashMap">HashMap</a>&lt;K, <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;V&gt;&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>&lt;Item = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>K, V<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>&gt; + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Return a <code>HashMap</code> of keys mapped to <code>Vec</code>s of values. Keys and values
are taken from <code>(Key, Value)</code> tuple pairs yielded by the input iterator.</p>
<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">data</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[(<span class="number">0</span>, <span class="number">10</span>), (<span class="number">2</span>, <span class="number">12</span>), (<span class="number">3</span>, <span class="number">13</span>), (<span class="number">0</span>, <span class="number">20</span>), (<span class="number">3</span>, <span class="number">33</span>), (<span class="number">2</span>, <span class="number">42</span>)];
<span class="kw">let</span> <span class="ident">lookup</span> <span class="op">=</span> <span class="ident">data</span>.<span class="ident">into_iter</span>().<span class="ident">into_group_map</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">lookup</span>[<span class="kw-2">&amp;</span><span class="number">0</span>], <span class="macro">vec</span><span class="macro">!</span>[<span class="number">10</span>, <span class="number">20</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">lookup</span>.<span class="ident">get</span>(<span class="kw-2">&amp;</span><span class="number">1</span>), <span class="prelude-val">None</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">lookup</span>[<span class="kw-2">&amp;</span><span class="number">2</span>], <span class="macro">vec</span><span class="macro">!</span>[<span class="number">12</span>, <span class="number">42</span>]);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">lookup</span>[<span class="kw-2">&amp;</span><span class="number">3</span>], <span class="macro">vec</span><span class="macro">!</span>[<span class="number">13</span>, <span class="number">33</span>]);</pre>
</div><h3 id='method.minmax' class='method'><span id='minmax.v' class='invisible'><code>fn <a href='#method.minmax' class='fnname'>minmax</a>(self) -&gt; <a class="enum" href="../itertools/enum.MinMaxResult.html" title="enum itertools::MinMaxResult">MinMaxResult</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Return the minimum and maximum elements in the iterator.</p>
<p>The return type <code>MinMaxResult</code> is an enum of three variants:</p>
<ul>
<li><code>NoElements</code> if the iterator is empty.</li>
<li><code>OneElement(x)</code> if the iterator has exactly one element.</li>
<li><code>MinMax(x, y)</code> is returned otherwise, where <code>x &lt;= y</code>. Two
values are equal if and only if there is more than one
element in the iterator and all elements are equal.</li>
</ul>
<p>On an iterator of length <code>n</code>, <code>minmax</code> does <code>1.5 * n</code> comparisons,
and so is faster than calling <code>min</code> and <code>max</code> separately which does
<code>2 * n</code> comparisons.</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">Itertools</span>;
<span class="kw">use</span> <span class="ident">itertools</span>::<span class="ident">MinMaxResult</span>::{<span class="ident">NoElements</span>, <span class="ident">OneElement</span>, <span class="ident">MinMax</span>};
<span class="kw">let</span> <span class="ident">a</span>: [<span class="ident">i32</span>; <span class="number">0</span>] <span class="op">=</span> [];
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">iter</span>().<span class="ident">minmax</span>(), <span class="ident">NoElements</span>);
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> [<span class="number">1</span>];
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">iter</span>().<span class="ident">minmax</span>(), <span class="ident">OneElement</span>(<span class="kw-2">&amp;</span><span class="number">1</span>));
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>];
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">iter</span>().<span class="ident">minmax</span>(), <span class="ident">MinMax</span>(<span class="kw-2">&amp;</span><span class="number">1</span>, <span class="kw-2">&amp;</span><span class="number">5</span>));
<span class="kw">let</span> <span class="ident">a</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>, <span class="number">1</span>];
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">a</span>.<span class="ident">iter</span>().<span class="ident">minmax</span>(), <span class="ident">MinMax</span>(<span class="kw-2">&amp;</span><span class="number">1</span>, <span class="kw-2">&amp;</span><span class="number">1</span>));</pre>
<p>The elements can be floats but no particular result is guaranteed
if an element is NaN.</p>
</div><h3 id='method.minmax_by_key' class='method'><span id='minmax_by_key.v' class='invisible'><code>fn <a href='#method.minmax_by_key' class='fnname'>minmax_by_key</a>&lt;K, F&gt;(self, key: F) -&gt; <a class="enum" href="../itertools/enum.MinMaxResult.html" title="enum itertools::MinMaxResult">MinMaxResult</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; K,&nbsp;</span></code></span></h3><div class='docblock'><p>Return the minimum and maximum element of an iterator, as determined by
the specified function.</p>
<p>The return value is a variant of <code>MinMaxResult</code> like for <code>minmax()</code>.</p>
<p>For the minimum, the first minimal element is returned. For the maximum,
the last maximal element wins. This matches the behavior of the standard
<code>Iterator::min()</code> and <code>Iterator::max()</code> methods.</p>
<p>The keys can be floats but no particular result is guaranteed
if a key is NaN.</p>
</div><h3 id='method.minmax_by' class='method'><span id='minmax_by.v' class='invisible'><code>fn <a href='#method.minmax_by' class='fnname'>minmax_by</a>&lt;F&gt;(self, compare: F) -&gt; <a class="enum" href="../itertools/enum.MinMaxResult.html" title="enum itertools::MinMaxResult">MinMaxResult</a>&lt;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Self: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnMut.html" title="trait core::ops::function::FnMut">FnMut</a>(&amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>, &amp;Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html#associatedtype.Item" title="type core::iter::iterator::Iterator::Item">Item</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a>,&nbsp;</span></code></span></h3><div class='docblock'><p>Return the minimum and maximum element of an iterator, as determined by
the specified comparison function.</p>
<p>The return value is a variant of <code>MinMaxResult</code> like for <code>minmax()</code>.</p>
<p>For the minimum, the first minimal element is returned. For the maximum,
the last maximal element wins. This matches the behavior of the standard
<code>Iterator::min()</code> and <code>Iterator::max()</code> methods.</p>
</div></div>
<h2 id='implementors' class='small-section-header'>
Implementors<a href='#implementors' class='anchor'></a>
</h2>
<ul class='item-list' id='implementors-list'>
<li><div class='out-of-band'><a class='srclink' href='../src/itertools/lib.rs.html#1988' title='goto source code'>[src]</a></div><code>impl&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt; Itertools for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/iterator/trait.Iterator.html" title="trait core::iter::iterator::Iterator">Iterator</a>,&nbsp;</span></code></li>
</ul><script type="text/javascript" async
src="../implementors/itertools/trait.Itertools.js">
</script></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>&#9166;</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>
</div>
</div>
</aside>
<script>
window.rootPath = "../";
window.currentCrate = "itertools";
</script>
<script src="../main.js"></script>
<script defer src="../search-index.js"></script>
</body>
</html>