| <!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="`ParallelDrainRange` creates a parallel iterator that moves a range of items from a collection while retaining the original capacity."><meta name="keywords" content="rust, rustlang, rust-lang, ParallelDrainRange"><title>ParallelDrainRange 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">☰</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="#">ParallelDrainRange</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-ParallelDrainRange%3Cusize%3E-for-%26%27a%20mut%20String">&'a mut String</a></li><li><a href="#impl-ParallelDrainRange%3Cusize%3E-for-%26%27a%20mut%20VecDeque%3CT%3E">&'a mut VecDeque<T></a></li><li><a href="#impl-ParallelDrainRange%3Cusize%3E-for-%26%27data%20mut%20Vec%3CT%3E">&'data mut Vec<T></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="#">ParallelDrainRange</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#3309-3376">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="item-decl"><pre class="rust trait"><code>pub trait ParallelDrainRange<Idx = usize> { |
| 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.ParallelDrainRange.html#associatedtype.Item" title="type rayon::iter::ParallelDrainRange::Item">Item</a>>; |
| type <a href="#associatedtype.Item" class="associatedtype">Item</a>: Send; |
| |
| fn <a href="#tymethod.par_drain" class="fnname">par_drain</a><R: RangeBounds<Idx>>(self, range: R) -> Self::<a class="associatedtype" href="trait.ParallelDrainRange.html#associatedtype.Iter" title="type rayon::iter::ParallelDrainRange::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>ParallelDrainRange</code> creates a parallel iterator that moves a range of items |
| from a collection while retaining the original capacity.</p> |
| <p>Types which are not indexable may implement <a href="trait.ParallelDrainFull.html"><code>ParallelDrainFull</code></a> instead.</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#3311">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.ParallelDrainRange.html#associatedtype.Item" title="type rayon::iter::ParallelDrainRange::Item">Item</a>></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#3315">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#3375">source</a><h4 class="code-header">fn <a href="#tymethod.par_drain" class="fnname">par_drain</a><R: RangeBounds<Idx>>(self, range: R) -> Self::<a class="associatedtype" href="trait.ParallelDrainRange.html#associatedtype.Iter" title="type rayon::iter::ParallelDrainRange::Iter">Iter</a></h4></section></summary><div class="docblock"><p>Returns a draining parallel iterator over a range of the collection.</p> |
| <p>When the iterator is dropped, all items in the range 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">let </span>squares: Vec<i32> = (<span class="number">0</span>..<span class="number">10</span>).map(|x| x * x).collect(); |
| |
| <span class="macro">println!</span>(<span class="string">"RangeFull"</span>); |
| <span class="kw">let </span><span class="kw-2">mut </span>vec = squares.clone(); |
| <span class="macro">assert!</span>(vec.par_drain(..) |
| .eq(squares.par_iter().copied())); |
| <span class="macro">assert!</span>(vec.is_empty()); |
| <span class="macro">assert!</span>(vec.capacity() >= squares.len()); |
| |
| <span class="macro">println!</span>(<span class="string">"RangeFrom"</span>); |
| <span class="kw">let </span><span class="kw-2">mut </span>vec = squares.clone(); |
| <span class="macro">assert!</span>(vec.par_drain(<span class="number">5</span>..) |
| .eq(squares[<span class="number">5</span>..].par_iter().copied())); |
| <span class="macro">assert_eq!</span>(<span class="kw-2">&</span>vec[..], <span class="kw-2">&</span>squares[..<span class="number">5</span>]); |
| <span class="macro">assert!</span>(vec.capacity() >= squares.len()); |
| |
| <span class="macro">println!</span>(<span class="string">"RangeTo"</span>); |
| <span class="kw">let </span><span class="kw-2">mut </span>vec = squares.clone(); |
| <span class="macro">assert!</span>(vec.par_drain(..<span class="number">5</span>) |
| .eq(squares[..<span class="number">5</span>].par_iter().copied())); |
| <span class="macro">assert_eq!</span>(<span class="kw-2">&</span>vec[..], <span class="kw-2">&</span>squares[<span class="number">5</span>..]); |
| <span class="macro">assert!</span>(vec.capacity() >= squares.len()); |
| |
| <span class="macro">println!</span>(<span class="string">"RangeToInclusive"</span>); |
| <span class="kw">let </span><span class="kw-2">mut </span>vec = squares.clone(); |
| <span class="macro">assert!</span>(vec.par_drain(..=<span class="number">5</span>) |
| .eq(squares[..=<span class="number">5</span>].par_iter().copied())); |
| <span class="macro">assert_eq!</span>(<span class="kw-2">&</span>vec[..], <span class="kw-2">&</span>squares[<span class="number">6</span>..]); |
| <span class="macro">assert!</span>(vec.capacity() >= squares.len()); |
| |
| <span class="macro">println!</span>(<span class="string">"Range"</span>); |
| <span class="kw">let </span><span class="kw-2">mut </span>vec = squares.clone(); |
| <span class="macro">assert!</span>(vec.par_drain(<span class="number">3</span>..<span class="number">7</span>) |
| .eq(squares[<span class="number">3</span>..<span class="number">7</span>].par_iter().copied())); |
| <span class="macro">assert_eq!</span>(<span class="kw-2">&</span>vec[..<span class="number">3</span>], <span class="kw-2">&</span>squares[..<span class="number">3</span>]); |
| <span class="macro">assert_eq!</span>(<span class="kw-2">&</span>vec[<span class="number">3</span>..], <span class="kw-2">&</span>squares[<span class="number">7</span>..]); |
| <span class="macro">assert!</span>(vec.capacity() >= squares.len()); |
| |
| <span class="macro">println!</span>(<span class="string">"RangeInclusive"</span>); |
| <span class="kw">let </span><span class="kw-2">mut </span>vec = squares.clone(); |
| <span class="macro">assert!</span>(vec.par_drain(<span class="number">3</span>..=<span class="number">7</span>) |
| .eq(squares[<span class="number">3</span>..=<span class="number">7</span>].par_iter().copied())); |
| <span class="macro">assert_eq!</span>(<span class="kw-2">&</span>vec[..<span class="number">3</span>], <span class="kw-2">&</span>squares[..<span class="number">3</span>]); |
| <span class="macro">assert_eq!</span>(<span class="kw-2">&</span>vec[<span class="number">3</span>..], <span class="kw-2">&</span>squares[<span class="number">8</span>..]); |
| <span class="macro">assert!</span>(vec.capacity() >= 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-ParallelDrainRange%3Cusize%3E-for-%26%27a%20mut%20VecDeque%3CT%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/rayon/collections/vec_deque.rs.html#100-111">source</a><a href="#impl-ParallelDrainRange%3Cusize%3E-for-%26%27a%20mut%20VecDeque%3CT%3E" class="anchor"></a><h3 class="code-header">impl<'a, T: Send> <a class="trait" href="trait.ParallelDrainRange.html" title="trait rayon::iter::ParallelDrainRange">ParallelDrainRange</a><usize> for &'a mut VecDeque<T></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/vec_deque/struct.Drain.html" title="struct rayon::collections::vec_deque::Drain">Drain</a><'a, T></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/vec_deque.rs.html#104-110">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><R: RangeBounds<usize>>(self, range: R) -> Self::<a class="associatedtype" href="trait.ParallelDrainRange.html#associatedtype.Iter" title="type rayon::iter::ParallelDrainRange::Iter">Iter</a></h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ParallelDrainRange%3Cusize%3E-for-%26%27a%20mut%20String" class="impl has-srclink"><a class="srclink rightside" href="../../src/rayon/string.rs.html#10-20">source</a><a href="#impl-ParallelDrainRange%3Cusize%3E-for-%26%27a%20mut%20String" class="anchor"></a><h3 class="code-header">impl<'a> <a class="trait" href="trait.ParallelDrainRange.html" title="trait rayon::iter::ParallelDrainRange">ParallelDrainRange</a><usize> for &'a mut String</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="../string/struct.Drain.html" title="struct rayon::string::Drain">Drain</a><'a></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> = char</h4></section><section id="method.par_drain-1" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/rayon/string.rs.html#14-19">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><R: RangeBounds<usize>>(self, range: R) -> Self::<a class="associatedtype" href="trait.ParallelDrainRange.html#associatedtype.Iter" title="type rayon::iter::ParallelDrainRange::Iter">Iter</a></h4></section></div></details><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-ParallelDrainRange%3Cusize%3E-for-%26%27data%20mut%20Vec%3CT%3E" class="impl has-srclink"><a class="srclink rightside" href="../../src/rayon/vec.rs.html#87-98">source</a><a href="#impl-ParallelDrainRange%3Cusize%3E-for-%26%27data%20mut%20Vec%3CT%3E" class="anchor"></a><h3 class="code-header">impl<'data, T: Send> <a class="trait" href="trait.ParallelDrainRange.html" title="trait rayon::iter::ParallelDrainRange">ParallelDrainRange</a><usize> for &'data mut Vec<T></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="../vec/struct.Drain.html" title="struct rayon::vec::Drain">Drain</a><'data, T></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/vec.rs.html#91-97">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><R: RangeBounds<usize>>(self, range: R) -> Self::<a class="associatedtype" href="trait.ParallelDrainRange.html#associatedtype.Iter" title="type rayon::iter::ParallelDrainRange::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.ParallelDrainRange.js" data-ignore-extern-crates="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> |