blob: a22df797f0097c7ad038fb14d5a0cae05cad015d [file] [log] [blame]
<!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="`ParallelDrainFull` creates a parallel iterator that moves all items from a collection while retaining the original capacity."><meta name="keywords" content="rust, rustlang, rust-lang, ParallelDrainFull"><title>ParallelDrainFull in rayon::iter - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../../normalize.css"><link rel="stylesheet" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../../ayu.css" disabled><link rel="stylesheet" href="../../dark.css" disabled><link rel="stylesheet" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../rayon/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../rayon/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">ParallelDrainFull</a></h2><div class="sidebar-elems"><section><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Item">Item</a></li><li><a href="#associatedtype.Iter">Iter</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.par_drain">par_drain</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-ParallelDrainFull-for-%26%27a%20mut%20BinaryHeap%3CT%3E">&amp;&#39;a mut BinaryHeap&lt;T&gt;</a></li><li><a href="#impl-ParallelDrainFull-for-%26%27a%20mut%20HashMap%3CK%2C%20V%2C%20S%3E">&amp;&#39;a mut HashMap&lt;K, V, S&gt;</a></li><li><a href="#impl-ParallelDrainFull-for-%26%27a%20mut%20HashSet%3CT%2C%20S%3E">&amp;&#39;a mut HashSet&lt;T, S&gt;</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><h2><a href="index.html">In rayon::iter</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Trait <a href="../index.html">rayon</a>::<wbr><a href="index.html">iter</a>::<wbr><a class="trait" href="#">ParallelDrainFull</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../../src/rayon/iter/mod.rs.html#3267-3301">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="item-decl"><pre class="rust trait"><code>pub trait ParallelDrainFull {
type <a href="#associatedtype.Iter" class="associatedtype">Iter</a>: <a class="trait" href="trait.ParallelIterator.html" title="trait rayon::iter::ParallelIterator">ParallelIterator</a>&lt;Item = Self::<a class="associatedtype" href="trait.ParallelDrainFull.html#associatedtype.Item" title="type rayon::iter::ParallelDrainFull::Item">Item</a>&gt;;
type <a href="#associatedtype.Item" class="associatedtype">Item</a>: Send;
fn <a href="#tymethod.par_drain" class="fnname">par_drain</a>(self) -&gt; Self::<a class="associatedtype" href="trait.ParallelDrainFull.html#associatedtype.Iter" title="type rayon::iter::ParallelDrainFull::Iter">Iter</a>;
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p><code>ParallelDrainFull</code> creates a parallel iterator that moves all items
from a collection while retaining the original capacity.</p>
<p>Types which are indexable typically implement <a href="trait.ParallelDrainRange.html"><code>ParallelDrainRange</code></a>
instead, where you can drain fully with <code>par_drain(..)</code>.</p>
</div></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="associatedtype.Iter" class="method has-srclink"><a class="srclink rightside" href="../../src/rayon/iter/mod.rs.html#3269">source</a><h4 class="code-header">type <a href="#associatedtype.Iter" class="associatedtype">Iter</a>: <a class="trait" href="trait.ParallelIterator.html" title="trait rayon::iter::ParallelIterator">ParallelIterator</a>&lt;Item = Self::<a class="associatedtype" href="trait.ParallelDrainFull.html#associatedtype.Item" title="type rayon::iter::ParallelDrainFull::Item">Item</a>&gt;</h4></section></summary><div class="docblock"><p>The draining parallel iterator type that will be created.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="associatedtype.Item" class="method has-srclink"><a class="srclink rightside" href="../../src/rayon/iter/mod.rs.html#3273">source</a><h4 class="code-header">type <a href="#associatedtype.Item" class="associatedtype">Item</a>: Send</h4></section></summary><div class="docblock"><p>The type of item that the parallel iterator will produce.
This is usually the same as <code>IntoParallelIterator::Item</code>.</p>
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="tymethod.par_drain" class="method has-srclink"><a class="srclink rightside" href="../../src/rayon/iter/mod.rs.html#3300">source</a><h4 class="code-header">fn <a href="#tymethod.par_drain" class="fnname">par_drain</a>(self) -&gt; Self::<a class="associatedtype" href="trait.ParallelDrainFull.html#associatedtype.Iter" title="type rayon::iter::ParallelDrainFull::Iter">Iter</a></h4></section></summary><div class="docblock"><p>Returns a draining parallel iterator over an entire collection.</p>
<p>When the iterator is dropped, all items are removed, even if the
iterator was not fully consumed. If the iterator is leaked, for example
using <code>std::mem::forget</code>, it is unspecified how many items are removed.</p>
<h5 id="examples"><a href="#examples">Examples</a></h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rayon::prelude::<span class="kw-2">*</span>;
<span class="kw">use </span>std::collections::{BinaryHeap, HashSet};
<span class="kw">let </span>squares: HashSet&lt;i32&gt; = (<span class="number">0</span>..<span class="number">10</span>).map(|x| x * x).collect();
<span class="kw">let </span><span class="kw-2">mut </span>heap: BinaryHeap&lt;<span class="kw">_</span>&gt; = squares.iter().copied().collect();
<span class="macro">assert_eq!</span>(
<span class="comment">// heaps are drained in arbitrary order
</span>heap.par_drain()
.inspect(|x| <span class="macro">assert!</span>(squares.contains(x)))
.count(),
squares.len(),
);
<span class="macro">assert!</span>(heap.is_empty());
<span class="macro">assert!</span>(heap.capacity() &gt;= squares.len());</code></pre></div>
</div></details></div><h2 id="foreign-impls" class="small-section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor"></a></h2><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ParallelDrainFull-for-%26%27a%20mut%20BinaryHeap%3CT%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/rayon/collections/binary_heap.rs.html#67-74">source</a><a href="#impl-ParallelDrainFull-for-%26%27a%20mut%20BinaryHeap%3CT%3E" class="anchor"></a><h3 class="code-header">impl&lt;'a, T:&nbsp;Ord + Send&gt; <a class="trait" href="trait.ParallelDrainFull.html" title="trait rayon::iter::ParallelDrainFull">ParallelDrainFull</a> for &amp;'a mut BinaryHeap&lt;T&gt;</h3></section></summary><div class="impl-items"><section id="associatedtype.Iter-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Iter-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Iter" class="associatedtype">Iter</a> = <a class="struct" href="../collections/binary_heap/struct.Drain.html" title="struct rayon::collections::binary_heap::Drain">Drain</a>&lt;'a, T&gt;</h4></section><section id="associatedtype.Item-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Item-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Item" class="associatedtype">Item</a> = T</h4></section><section id="method.par_drain" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/rayon/collections/binary_heap.rs.html#71-73">source</a><a href="#method.par_drain" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.par_drain" class="fnname">par_drain</a>(self) -&gt; Self::<a class="associatedtype" href="trait.ParallelDrainFull.html#associatedtype.Iter" title="type rayon::iter::ParallelDrainFull::Iter">Iter</a></h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ParallelDrainFull-for-%26%27a%20mut%20HashMap%3CK%2C%20V%2C%20S%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/rayon/collections/hash_map.rs.html#78-91">source</a><a href="#impl-ParallelDrainFull-for-%26%27a%20mut%20HashMap%3CK%2C%20V%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;'a, K:&nbsp;Hash + Eq + Send, V:&nbsp;Send, S:&nbsp;BuildHasher&gt; <a class="trait" href="trait.ParallelDrainFull.html" title="trait rayon::iter::ParallelDrainFull">ParallelDrainFull</a> for &amp;'a mut HashMap&lt;K, V, S&gt;</h3></section></summary><div class="impl-items"><section id="associatedtype.Iter-2" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Iter-2" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Iter" class="associatedtype">Iter</a> = <a class="struct" href="../collections/hash_map/struct.Drain.html" title="struct rayon::collections::hash_map::Drain">Drain</a>&lt;'a, K, V&gt;</h4></section><section id="associatedtype.Item-2" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Item-2" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Item" class="associatedtype">Item</a> = (K, V)</h4></section><section id="method.par_drain-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/rayon/collections/hash_map.rs.html#84-90">source</a><a href="#method.par_drain-1" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.par_drain" class="fnname">par_drain</a>(self) -&gt; Self::<a class="associatedtype" href="trait.ParallelDrainFull.html#associatedtype.Iter" title="type rayon::iter::ParallelDrainFull::Iter">Iter</a></h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ParallelDrainFull-for-%26%27a%20mut%20HashSet%3CT%2C%20S%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/rayon/collections/hash_set.rs.html#64-75">source</a><a href="#impl-ParallelDrainFull-for-%26%27a%20mut%20HashSet%3CT%2C%20S%3E" class="anchor"></a><h3 class="code-header">impl&lt;'a, T:&nbsp;Hash + Eq + Send, S:&nbsp;BuildHasher&gt; <a class="trait" href="trait.ParallelDrainFull.html" title="trait rayon::iter::ParallelDrainFull">ParallelDrainFull</a> for &amp;'a mut HashSet&lt;T, S&gt;</h3></section></summary><div class="impl-items"><section id="associatedtype.Iter-3" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Iter-3" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Iter" class="associatedtype">Iter</a> = <a class="struct" href="../collections/hash_set/struct.Drain.html" title="struct rayon::collections::hash_set::Drain">Drain</a>&lt;'a, T&gt;</h4></section><section id="associatedtype.Item-3" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Item-3" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Item" class="associatedtype">Item</a> = T</h4></section><section id="method.par_drain-2" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/rayon/collections/hash_set.rs.html#68-74">source</a><a href="#method.par_drain-2" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.par_drain" class="fnname">par_drain</a>(self) -&gt; Self::<a class="associatedtype" href="trait.ParallelDrainFull.html#associatedtype.Iter" title="type rayon::iter::ParallelDrainFull::Iter">Iter</a></h4></section></div></details><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div id="implementors-list"></div><script src="../../implementors/rayon/iter/trait.ParallelDrainFull.js" data-ignore-extern-crates="std,alloc" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="rayon" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>