33 lines
16 KiB
HTML
33 lines
16 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="`ParallelDrainFull` creates a parallel iterator that moves all items from a collection while retaining the original capacity."><title>ParallelDrainFull in rayon::iter - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="rayon" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.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]--><rustdoc-topbar><h2><a href="#">ParallelDrainFull</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../rayon/index.html">rayon</a><span class="version">1.11.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Parallel<wbr>Drain<wbr>Full</a></h2><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Item" title="Item">Item</a></li><li><a href="#associatedtype.Iter" title="Iter">Iter</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.par_drain" title="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-%26mut+BinaryHeap%3CT%3E" title="&'a mut BinaryHeap<T>">&'a mut BinaryHeap<T></a></li><li><a href="#impl-ParallelDrainFull-for-%26mut+HashMap%3CK,+V,+S%3E" title="&'a mut HashMap<K, V, S>">&'a mut HashMap<K, V, S></a></li><li><a href="#impl-ParallelDrainFull-for-%26mut+HashSet%3CT,+S%3E" title="&'a mut HashSet<T, S>">&'a mut HashSet<T, S></a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In rayon::<wbr>iter</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">rayon</a>::<wbr><a href="index.html">iter</a></div><h1>Trait <span class="trait">Parallel<wbr>Drain<wbr>Full</span> <button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/rayon/iter/mod.rs.html#3360-3394">Source</a> </span></div><pre class="rust item-decl"><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><Item = Self::<a class="associatedtype" href="trait.ParallelDrainFull.html#associatedtype.Item" title="type rayon::iter::ParallelDrainFull::Item">Item</a>>;
|
|
type <a href="#associatedtype.Item" class="associatedtype">Item</a>: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>;
|
|
|
|
// Required method
|
|
fn <a href="#tymethod.par_drain" class="fn">par_drain</a>(self) -> Self::<a class="associatedtype" href="trait.ParallelDrainFull.html#associatedtype.Iter" title="type rayon::iter::ParallelDrainFull::Iter">Iter</a>;
|
|
}</code></pre><details class="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" title="trait rayon::iter::ParallelDrainRange"><code>ParallelDrainRange</code></a>
|
|
instead, where you can drain fully with <code>par_drain(..)</code>.</p>
|
|
</div></details><h2 id="required-associated-types" class="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Iter" class="method"><a class="src rightside" href="../../src/rayon/iter/mod.rs.html#3362">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><Item = Self::<a class="associatedtype" href="trait.ParallelDrainFull.html#associatedtype.Item" title="type rayon::iter::ParallelDrainFull::Item">Item</a>></h4></section></summary><div class="docblock"><p>The draining parallel iterator type that will be created.</p>
|
|
</div></details><details class="toggle" open><summary><section id="associatedtype.Item" class="method"><a class="src rightside" href="../../src/rayon/iter/mod.rs.html#3366">Source</a><h4 class="code-header">type <a href="#associatedtype.Item" class="associatedtype">Item</a>: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a></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="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.par_drain" class="method"><a class="src rightside" href="../../src/rayon/iter/mod.rs.html#3393">Source</a><h4 class="code-header">fn <a href="#tymethod.par_drain" class="fn">par_drain</a>(self) -> 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 class="doc-anchor" href="#examples">§</a>Examples</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<i32> = (<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<<span class="kw">_</span>> = 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() >= squares.len());</code></pre></div></div></details></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-ParallelDrainFull-for-%26mut+HashMap%3CK,+V,+S%3E" class="impl"><a class="src rightside" href="../../src/rayon/collections/hash_map.rs.html#77-88">Source</a><a href="#impl-ParallelDrainFull-for-%26mut+HashMap%3CK,+V,+S%3E" class="anchor">§</a><h3 class="code-header">impl<'a, K: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, V: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, S> <a class="trait" href="trait.ParallelDrainFull.html" title="trait rayon::iter::ParallelDrainFull">ParallelDrainFull</a> for &'a mut <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/collections/hash/map/struct.HashMap.html" title="struct std::collections::hash::map::HashMap">HashMap</a><K, V, S></h3></section></summary><div class="impl-items"><section id="associatedtype.Iter-1" class="associatedtype trait-impl"><a class="src rightside" href="../../src/rayon/collections/hash_map.rs.html#78">Source</a><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/hash_map/struct.Drain.html" title="struct rayon::collections::hash_map::Drain">Drain</a><'a, K, V></h4></section><section id="associatedtype.Item-1" class="associatedtype trait-impl"><a class="src rightside" href="../../src/rayon/collections/hash_map.rs.html#79">Source</a><a href="#associatedtype.Item-1" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Item" class="associatedtype">Item</a> = <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.tuple.html">(K, V)</a></h4></section><section id="method.par_drain" class="method trait-impl"><a class="src rightside" href="../../src/rayon/collections/hash_map.rs.html#81-87">Source</a><a href="#method.par_drain" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.par_drain" class="fn">par_drain</a>(self) -> Self::<a class="associatedtype" href="trait.ParallelDrainFull.html#associatedtype.Iter" title="type rayon::iter::ParallelDrainFull::Iter">Iter</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-ParallelDrainFull-for-%26mut+BinaryHeap%3CT%3E" class="impl"><a class="src rightside" href="../../src/rayon/collections/binary_heap.rs.html#76-83">Source</a><a href="#impl-ParallelDrainFull-for-%26mut+BinaryHeap%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<'a, T: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a> + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>> <a class="trait" href="trait.ParallelDrainFull.html" title="trait rayon::iter::ParallelDrainFull">ParallelDrainFull</a> for &'a mut <a class="struct" href="https://doc.rust-lang.org/1.93.1/alloc/collections/binary_heap/struct.BinaryHeap.html" title="struct alloc::collections::binary_heap::BinaryHeap">BinaryHeap</a><T></h3></section></summary><div class="impl-items"><section id="associatedtype.Iter-2" class="associatedtype trait-impl"><a class="src rightside" href="../../src/rayon/collections/binary_heap.rs.html#77">Source</a><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/binary_heap/struct.Drain.html" title="struct rayon::collections::binary_heap::Drain">Drain</a><'a, T></h4></section><section id="associatedtype.Item-2" class="associatedtype trait-impl"><a class="src rightside" href="../../src/rayon/collections/binary_heap.rs.html#78">Source</a><a href="#associatedtype.Item-2" class="anchor">§</a><h4 class="code-header">type <a href="#associatedtype.Item" class="associatedtype">Item</a> = T</h4></section><section id="method.par_drain-1" class="method trait-impl"><a class="src rightside" href="../../src/rayon/collections/binary_heap.rs.html#80-82">Source</a><a href="#method.par_drain-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.par_drain" class="fn">par_drain</a>(self) -> Self::<a class="associatedtype" href="trait.ParallelDrainFull.html#associatedtype.Iter" title="type rayon::iter::ParallelDrainFull::Iter">Iter</a></h4></section></div></details><details class="toggle implementors-toggle"><summary><section id="impl-ParallelDrainFull-for-%26mut+HashSet%3CT,+S%3E" class="impl"><a class="src rightside" href="../../src/rayon/collections/hash_set.rs.html#63-74">Source</a><a href="#impl-ParallelDrainFull-for-%26mut+HashSet%3CT,+S%3E" class="anchor">§</a><h3 class="code-header">impl<'a, T: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, S> <a class="trait" href="trait.ParallelDrainFull.html" title="trait rayon::iter::ParallelDrainFull">ParallelDrainFull</a> for &'a mut <a class="struct" href="https://doc.rust-lang.org/1.93.1/std/collections/hash/set/struct.HashSet.html" title="struct std::collections::hash::set::HashSet">HashSet</a><T, S></h3></section></summary><div class="impl-items"><section id="associatedtype.Iter-3" class="associatedtype trait-impl"><a class="src rightside" href="../../src/rayon/collections/hash_set.rs.html#64">Source</a><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><'a, T></h4></section><section id="associatedtype.Item-3" class="associatedtype trait-impl"><a class="src rightside" href="../../src/rayon/collections/hash_set.rs.html#65">Source</a><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"><a class="src rightside" href="../../src/rayon/collections/hash_set.rs.html#67-73">Source</a><a href="#method.par_drain-2" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.par_drain" class="fn">par_drain</a>(self) -> 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="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../../trait.impl/rayon/iter/trait.ParallelDrainFull.js" data-ignore-extern-crates="alloc,std" async></script></section></div></main></body></html> |