blob: 33d1256114a9f82e783ee8e641cd26598ff5ad0e [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="Parallel extensions for slices."><meta name="keywords" content="rust, rustlang, rust-lang, ParallelSlice"><title>ParallelSlice in rayon::slice - 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="#">ParallelSlice</a></h2><div class="sidebar-elems"><section><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.as_parallel_slice">as_parallel_slice</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.par_chunks">par_chunks</a></li><li><a href="#method.par_chunks_exact">par_chunks_exact</a></li><li><a href="#method.par_rchunks">par_rchunks</a></li><li><a href="#method.par_rchunks_exact">par_rchunks_exact</a></li><li><a href="#method.par_split">par_split</a></li><li><a href="#method.par_windows">par_windows</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-ParallelSlice%3CT%3E-for-%5BT%5D">[T]</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><h2><a href="index.html">In rayon::slice</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">slice</a>::<wbr><a class="trait" href="#">ParallelSlice</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/slice/mod.rs.html#29-153">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 ParallelSlice&lt;T:&nbsp;Sync&gt; {
fn <a href="#tymethod.as_parallel_slice" class="fnname">as_parallel_slice</a>(&amp;self) -&gt; &amp;[T];
fn <a href="#method.par_split" class="fnname">par_split</a>&lt;P&gt;(&amp;self, separator: P) -&gt; <a class="struct" href="struct.Split.html" title="struct rayon::slice::Split">Split</a>&lt;'_, T, P&gt;<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;P: Fn(&amp;T) -&gt; bool + Sync + Send</span>,
{ ... }
<span class="item-spacer"></span> fn <a href="#method.par_windows" class="fnname">par_windows</a>(&amp;self, window_size: usize) -&gt; <a class="struct" href="struct.Windows.html" title="struct rayon::slice::Windows">Windows</a>&lt;'_, T&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.par_chunks" class="fnname">par_chunks</a>(&amp;self, chunk_size: usize) -&gt; <a class="struct" href="struct.Chunks.html" title="struct rayon::slice::Chunks">Chunks</a>&lt;'_, T&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.par_chunks_exact" class="fnname">par_chunks_exact</a>(&amp;self, chunk_size: usize) -&gt; <a class="struct" href="struct.ChunksExact.html" title="struct rayon::slice::ChunksExact">ChunksExact</a>&lt;'_, T&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.par_rchunks" class="fnname">par_rchunks</a>(&amp;self, chunk_size: usize) -&gt; <a class="struct" href="struct.RChunks.html" title="struct rayon::slice::RChunks">RChunks</a>&lt;'_, T&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.par_rchunks_exact" class="fnname">par_rchunks_exact</a>(&amp;self, chunk_size: usize) -&gt; <a class="struct" href="struct.RChunksExact.html" title="struct rayon::slice::RChunksExact">RChunksExact</a>&lt;'_, T&gt; { ... }
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Parallel extensions for slices.</p>
</div></details><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.as_parallel_slice" class="method has-srclink"><a class="srclink rightside" href="../../src/rayon/slice/mod.rs.html#32">source</a><h4 class="code-header">fn <a href="#tymethod.as_parallel_slice" class="fnname">as_parallel_slice</a>(&amp;self) -&gt; &amp;[T]</h4></section></summary><div class="docblock"><p>Returns a plain slice, which is used to implement the rest of the
parallel methods.</p>
</div></details></div><h2 id="provided-methods" class="small-section-header">Provided Methods<a href="#provided-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.par_split" class="method has-srclink"><a class="srclink rightside" href="../../src/rayon/slice/mod.rs.html#47-55">source</a><h4 class="code-header">fn <a href="#method.par_split" class="fnname">par_split</a>&lt;P&gt;(&amp;self, separator: P) -&gt; <a class="struct" href="struct.Split.html" title="struct rayon::slice::Split">Split</a>&lt;'_, T, P&gt;<span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;P: Fn(&amp;T) -&gt; bool + Sync + Send,</span></h4></section></summary><div class="docblock"><p>Returns a parallel iterator over subslices separated by elements that
match the separator.</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>smallest = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">0</span>, <span class="number">2</span>, <span class="number">4</span>, <span class="number">8</span>, <span class="number">0</span>, <span class="number">3</span>, <span class="number">6</span>, <span class="number">9</span>]
.par_split(|i| <span class="kw-2">*</span>i == <span class="number">0</span>)
.map(|numbers| numbers.iter().min().unwrap())
.min();
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="number">1</span>), smallest);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.par_windows" class="method has-srclink"><a class="srclink rightside" href="../../src/rayon/slice/mod.rs.html#67-72">source</a><h4 class="code-header">fn <a href="#method.par_windows" class="fnname">par_windows</a>(&amp;self, window_size: usize) -&gt; <a class="struct" href="struct.Windows.html" title="struct rayon::slice::Windows">Windows</a>&lt;'_, T&gt;</h4></section></summary><div class="docblock"><p>Returns a parallel iterator over all contiguous windows of length
<code>window_size</code>. The windows overlap.</p>
<h5 id="examples-1"><a href="#examples-1">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>windows: Vec&lt;<span class="kw">_</span>&gt; = [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>].par_windows(<span class="number">2</span>).collect();
<span class="macro">assert_eq!</span>(<span class="macro">vec!</span>[[<span class="number">1</span>, <span class="number">2</span>], [<span class="number">2</span>, <span class="number">3</span>]], windows);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.par_chunks" class="method has-srclink"><a class="srclink rightside" href="../../src/rayon/slice/mod.rs.html#89-92">source</a><h4 class="code-header">fn <a href="#method.par_chunks" class="fnname">par_chunks</a>(&amp;self, chunk_size: usize) -&gt; <a class="struct" href="struct.Chunks.html" title="struct rayon::slice::Chunks">Chunks</a>&lt;'_, T&gt;</h4></section></summary><div class="docblock"><p>Returns a parallel iterator over at most <code>chunk_size</code> elements of
<code>self</code> at a time. The chunks do not overlap.</p>
<p>If the number of elements in the iterator is not divisible by
<code>chunk_size</code>, the last chunk may be shorter than <code>chunk_size</code>. All
other chunks will have that exact length.</p>
<h5 id="examples-2"><a href="#examples-2">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>chunks: Vec&lt;<span class="kw">_</span>&gt; = [<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>].par_chunks(<span class="number">2</span>).collect();
<span class="macro">assert_eq!</span>(chunks, <span class="macro">vec!</span>[<span class="kw-2">&amp;</span>[<span class="number">1</span>, <span class="number">2</span>][..], <span class="kw-2">&amp;</span>[<span class="number">3</span>, <span class="number">4</span>], <span class="kw-2">&amp;</span>[<span class="number">5</span>]]);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.par_chunks_exact" class="method has-srclink"><a class="srclink rightside" href="../../src/rayon/slice/mod.rs.html#109-112">source</a><h4 class="code-header">fn <a href="#method.par_chunks_exact" class="fnname">par_chunks_exact</a>(&amp;self, chunk_size: usize) -&gt; <a class="struct" href="struct.ChunksExact.html" title="struct rayon::slice::ChunksExact">ChunksExact</a>&lt;'_, T&gt;</h4></section></summary><div class="docblock"><p>Returns a parallel iterator over <code>chunk_size</code> elements of
<code>self</code> at a time. The chunks do not overlap.</p>
<p>If <code>chunk_size</code> does not divide the length of the slice, then the
last up to <code>chunk_size-1</code> elements will be omitted and can be
retrieved from the remainder function of the iterator.</p>
<h5 id="examples-3"><a href="#examples-3">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>chunks: Vec&lt;<span class="kw">_</span>&gt; = [<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>].par_chunks_exact(<span class="number">2</span>).collect();
<span class="macro">assert_eq!</span>(chunks, <span class="macro">vec!</span>[<span class="kw-2">&amp;</span>[<span class="number">1</span>, <span class="number">2</span>][..], <span class="kw-2">&amp;</span>[<span class="number">3</span>, <span class="number">4</span>]]);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.par_rchunks" class="method has-srclink"><a class="srclink rightside" href="../../src/rayon/slice/mod.rs.html#129-132">source</a><h4 class="code-header">fn <a href="#method.par_rchunks" class="fnname">par_rchunks</a>(&amp;self, chunk_size: usize) -&gt; <a class="struct" href="struct.RChunks.html" title="struct rayon::slice::RChunks">RChunks</a>&lt;'_, T&gt;</h4></section></summary><div class="docblock"><p>Returns a parallel iterator over at most <code>chunk_size</code> elements of <code>self</code> at a time,
starting at the end. The chunks do not overlap.</p>
<p>If the number of elements in the iterator is not divisible by
<code>chunk_size</code>, the last chunk may be shorter than <code>chunk_size</code>. All
other chunks will have that exact length.</p>
<h5 id="examples-4"><a href="#examples-4">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>chunks: Vec&lt;<span class="kw">_</span>&gt; = [<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>].par_rchunks(<span class="number">2</span>).collect();
<span class="macro">assert_eq!</span>(chunks, <span class="macro">vec!</span>[<span class="kw-2">&amp;</span>[<span class="number">4</span>, <span class="number">5</span>][..], <span class="kw-2">&amp;</span>[<span class="number">2</span>, <span class="number">3</span>], <span class="kw-2">&amp;</span>[<span class="number">1</span>]]);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.par_rchunks_exact" class="method has-srclink"><a class="srclink rightside" href="../../src/rayon/slice/mod.rs.html#149-152">source</a><h4 class="code-header">fn <a href="#method.par_rchunks_exact" class="fnname">par_rchunks_exact</a>(&amp;self, chunk_size: usize) -&gt; <a class="struct" href="struct.RChunksExact.html" title="struct rayon::slice::RChunksExact">RChunksExact</a>&lt;'_, T&gt;</h4></section></summary><div class="docblock"><p>Returns a parallel iterator over <code>chunk_size</code> elements of <code>self</code> at a time,
starting at the end. The chunks do not overlap.</p>
<p>If <code>chunk_size</code> does not divide the length of the slice, then the
last up to <code>chunk_size-1</code> elements will be omitted and can be
retrieved from the remainder function of the iterator.</p>
<h5 id="examples-5"><a href="#examples-5">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>chunks: Vec&lt;<span class="kw">_</span>&gt; = [<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>].par_rchunks_exact(<span class="number">2</span>).collect();
<span class="macro">assert_eq!</span>(chunks, <span class="macro">vec!</span>[<span class="kw-2">&amp;</span>[<span class="number">4</span>, <span class="number">5</span>][..], <span class="kw-2">&amp;</span>[<span class="number">2</span>, <span class="number">3</span>]]);</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-ParallelSlice%3CT%3E-for-%5BT%5D" class="impl has-srclink"><a class="srclink rightside" href="../../src/rayon/slice/mod.rs.html#155-160">source</a><a href="#impl-ParallelSlice%3CT%3E-for-%5BT%5D" class="anchor"></a><h3 class="code-header">impl&lt;T:&nbsp;Sync&gt; <a class="trait" href="trait.ParallelSlice.html" title="trait rayon::slice::ParallelSlice">ParallelSlice</a>&lt;T&gt; for [T]</h3></section></summary><div class="impl-items"><section id="method.as_parallel_slice" class="method trait-impl has-srclink"><a class="srclink rightside" href="../../src/rayon/slice/mod.rs.html#157-159">source</a><a href="#method.as_parallel_slice" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.as_parallel_slice" class="fnname">as_parallel_slice</a>(&amp;self) -&gt; &amp;[T]</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/slice/trait.ParallelSlice.js" data-ignore-extern-crates="core" 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>