|
|
|
|
<!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 `FromParallelIterator` trait in crate `rayon`."><meta name="keywords" content="rust, rustlang, rust-lang, FromParallelIterator"><title>rayon::iter::FromParallelIterator - 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="../../light.css" id="themeStyle"><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="shortcut icon" href="../../favicon.ico"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></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">☰</div><a href='../../rayon/index.html'><div class='logo-container'><img src='../../rust-logo.png' alt='logo'></div></a><p class='location'>Trait FromParallelIterator</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.from_par_iter">from_par_iter</a></div><a class="sidebar-title" href="#foreign-impls">Implementations on Foreign Types</a><div class="sidebar-links"><a href="#impl-FromParallelIterator%3C%26%27a%20char%3E-for-String">String</a><a href="#impl-FromParallelIterator%3C%26%27a%20str%3E-for-String">String</a><a href="#impl-FromParallelIterator%3C()%3E-for-()">()</a><a href="#impl-FromParallelIterator%3C(K%2C%20V)%3E-for-BTreeMap%3CK%2C%20V%3E">BTreeMap<K, V></a><a href="#impl-FromParallelIterator%3C(K%2C%20V)%3E-for-HashMap%3CK%2C%20V%2C%20S%3E">HashMap<K, V, S></a><a href="#impl-FromParallelIterator%3CCow%3C%27a%2C%20str%3E%3E-for-String">String</a><a href="#impl-FromParallelIterator%3COption%3CT%3E%3E-for-Option%3CC%3E">Option<C></a><a href="#impl-FromParallelIterator%3CResult%3CT%2C%20E%3E%3E-for-Result%3CC%2C%20E%3E">Result<C, E></a><a href="#impl-FromParallelIterator%3CString%3E-for-String">String</a><a href="#impl-FromParallelIterator%3CT%3E-for-BinaryHeap%3CT%3E">BinaryHeap<T></a><a href="#impl-FromParallelIterator%3CT%3E-for-Cow%3C%27a%2C%20C%3E">Cow<'a, C></a><a href="#impl-FromParallelIterator%3CT%3E-for-LinkedList%3CT%3E">LinkedList<T></a><a href="#impl-FromParallelIterator%3CT%3E-for-Vec%3CT%3E">Vec<T></a><a href="#impl-FromParallelIterator%3CT%3E-for-VecDeque%3CT%3E">VecDeque<T></a><a href="#impl-FromParallelIterator%3CV%3E-for-BTreeSet%3CV%3E">BTreeSet<V></a><a href="#impl-FromParallelIterator%3CV%3E-for-HashSet%3CV%2C%20S%3E">HashSet<V, S></a><a href="#impl-FromParallelIterator%3Cchar%3E-for-String">String</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='../index.html'>rayon</a>::<wbr><a href='index.html'>iter</a></p><script>window.sidebarCurrent = {name: 'FromParallelIterator', 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"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><a id="settings-menu" href="../../settings.html"><img src="../../whe
|
|
|
|
|
fn <a href='#tymethod.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self<br> <span class="where">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><Item = T></span>;
|
|
|
|
|
}</pre></div><div class='docblock'><p><code>FromParallelIterator</code> implements the creation of a collection
|
|
|
|
|
from a <a href="trait.ParallelIterator.html"><code>ParallelIterator</code></a>. By implementing
|
|
|
|
|
<code>FromParallelIterator</code> for a given type, you define how it will be
|
|
|
|
|
created from an iterator.</p>
|
|
|
|
|
<p><code>FromParallelIterator</code> is used through <a href="trait.ParallelIterator.html"><code>ParallelIterator</code></a>'s <a href="trait.ParallelIterator.html#method.collect"><code>collect()</code></a> method.</p>
|
|
|
|
|
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
|
|
|
|
<p>Implementing <code>FromParallelIterator</code> for your type:</p>
|
|
|
|
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
|
|
<span class="kw">use</span> <span class="ident">rayon</span>::<span class="ident">prelude</span>::<span class="kw-2">*</span>;
|
|
|
|
|
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">mem</span>;
|
|
|
|
|
|
|
|
|
|
<span class="kw">struct</span> <span class="ident">BlackHole</span> {
|
|
|
|
|
<span class="ident">mass</span>: <span class="ident">usize</span>,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<span class="kw">impl</span><span class="op"><</span><span class="ident">T</span>: <span class="ident">Send</span><span class="op">></span> <span class="ident">FromParallelIterator</span><span class="op"><</span><span class="ident">T</span><span class="op">></span> <span class="kw">for</span> <span class="ident">BlackHole</span> {
|
|
|
|
|
<span class="kw">fn</span> <span class="ident">from_par_iter</span><span class="op"><</span><span class="ident">I</span><span class="op">></span>(<span class="ident">par_iter</span>: <span class="ident">I</span>) <span class="op">-</span><span class="op">></span> <span class="self">Self</span>
|
|
|
|
|
<span class="kw">where</span> <span class="ident">I</span>: <span class="ident">IntoParallelIterator</span><span class="op"><</span><span class="ident">Item</span> <span class="op">=</span> <span class="ident">T</span><span class="op">></span>
|
|
|
|
|
{
|
|
|
|
|
<span class="kw">let</span> <span class="ident">par_iter</span> <span class="op">=</span> <span class="ident">par_iter</span>.<span class="ident">into_par_iter</span>();
|
|
|
|
|
<span class="ident">BlackHole</span> {
|
|
|
|
|
<span class="ident">mass</span>: <span class="ident">par_iter</span>.<span class="ident">count</span>() <span class="op">*</span> <span class="ident">mem</span>::<span class="ident">size_of</span>::<span class="op"><</span><span class="ident">T</span><span class="op">></span>(),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
<span class="kw">let</span> <span class="ident">bh</span>: <span class="ident">BlackHole</span> <span class="op">=</span> (<span class="number">0i32</span>..<span class="number">1000</span>).<span class="ident">into_par_iter</span>().<span class="ident">collect</span>();
|
|
|
|
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">bh</span>.<span class="ident">mass</span>, <span class="number">4000</span>);</pre></div>
|
|
|
|
|
</div>
|
|
|
|
|
<h2 id='required-methods' class='small-section-header'>Required methods<a href='#required-methods' class='anchor'></a></h2><div class='methods'><h3 id='tymethod.from_par_iter' class='method'><code id='from_par_iter.v'>fn <a href='#tymethod.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self <span class="where fmt-newline">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><Item = T>, </span></code></h3><div class='docblock'><p>Creates an instance of the collection from the parallel iterator <code>par_iter</code>.</p>
|
|
|
|
|
<p>If your collection is not naturally parallel, the easiest (and
|
|
|
|
|
fastest) way to do this is often to collect <code>par_iter</code> into a
|
|
|
|
|
<a href="https://doc.rust-lang.org/std/collections/struct.LinkedList.html"><code>LinkedList</code></a> or other intermediate data structure and then
|
|
|
|
|
sequentially extend your collection. However, a more 'native'
|
|
|
|
|
technique is to use the <a href="trait.ParallelIterator.html#method.fold"><code>par_iter.fold</code></a> or
|
|
|
|
|
<a href="trait.ParallelIterator.html#method.fold_with"><code>par_iter.fold_with</code></a> methods to create the collection.
|
|
|
|
|
Alternatively, if your collection is 'natively' parallel, you
|
|
|
|
|
can use <code>par_iter.for_each</code> to process each element in turn.</p>
|
|
|
|
|
</div></div><span class='loading-content'>Loading content...</span>
|
|
|
|
|
<h2 id='foreign-impls' class='small-section-header'>Implementations on Foreign Types<a href='#foreign-impls' class='anchor'></a></h2><h3 id='impl-FromParallelIterator%3CT%3E-for-Vec%3CT%3E' class='impl'><code class='in-band'>impl<T> <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><T> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, </span></code><a href='#impl-FromParallelIterator%3CT%3E-for-Vec%3CT%3E' class='anchor'></a><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#21-31' title='goto source code'>[src]</a></h3><div class='docblock'><p>Collect items from a parallel iterator into a vector.</p>
|
|
|
|
|
</div><div class='impl-items'><h4 id='method.from_par_iter' class="method hidden"><code id='from_par_iter.v-1'>fn <a href='#method.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self <span class="where fmt-newline">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><Item = T>, </span></code><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#25-30' title='goto source code'>[src]</a></h4></div><h3 id='impl-FromParallelIterator%3CT%3E-for-VecDeque%3CT%3E' class='impl'><code class='in-band'>impl<T> <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><T> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/vec_deque/struct.VecDeque.html" title="struct alloc::collections::vec_deque::VecDeque">VecDeque</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, </span></code><a href='#impl-FromParallelIterator%3CT%3E-for-VecDeque%3CT%3E' class='anchor'></a><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#34-44' title='goto source code'>[src]</a></h3><div class='docblock'><p>Collect items from a parallel iterator into a vecdeque.</p>
|
|
|
|
|
</div><div class='impl-items'><h4 id='method.from_par_iter-1' class="method hidden"><code id='from_par_iter.v-2'>fn <a href='#method.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self <span class="where fmt-newline">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><Item = T>, </span></code><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#38-43' title='goto source code'>[src]</a></h4></div><h3 id='impl-FromParallelIterator%3CT%3E-for-BinaryHeap%3CT%3E' class='impl'><code class='in-band'>impl<T> <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><T> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/binary_heap/struct.BinaryHeap.html" title="struct alloc::collections::binary_heap::BinaryHeap">BinaryHeap</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, </span></code><a href='#impl-FromParallelIterator%3CT%3E-for-BinaryHeap%3CT%3E' class='anchor'></a><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#48-58' title='goto source code'>[src]</a></h3><div class='docblock'><p>Collect items from a parallel iterator into a binaryheap.
|
|
|
|
|
The heap-ordering is calculated serially after all items are collected.</p>
|
|
|
|
|
</div><div class='impl-items'><h4 id='method.from_par_iter-2' class="method hidden"><code id='from_par_iter.v-3'>fn <a href='#method.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self <span class="where fmt-newline">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><Item = T>, </span></code><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#52-57' title='goto source code'>[src]</a></h4></div><h3 id='impl-FromParallelIterator%3CT%3E-for-LinkedList%3CT%3E' class='impl'><code class='in-band'>impl<T> <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><T> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/linked_list/struct.LinkedList.html" title="struct alloc::collections::linked_list::LinkedList">LinkedList</a><T> <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, </span></code><a href='#impl-FromParallelIterator%3CT%3E-for-LinkedList%3CT%3E' class='anchor'></a><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#62-72' title='goto source code'>[src]</a></h3><div class='docblock'><p>Collect items from a parallel iterator into a freshly allocated
|
|
|
|
|
linked list.</p>
|
|
|
|
|
</div><div class='impl-items'><h4 id='method.from_par_iter-3' class="method hidden"><code id='from_par_iter.v-4'>fn <a href='#method.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self <span class="where fmt-newline">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><Item = T>, </span></code><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#66-71' title='goto source code'>[src]</a></h4></div><h3 id='impl-FromParallelIterator%3C(K%2C%20V)%3E-for-HashMap%3CK%2C%20V%2C%20S%3E' class='impl'><code class='in-band'>impl<K, V, S> <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><<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>> for <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><K, V, S> <span class="where fmt-newline">where<br> K: <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/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,<br> V: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,<br> S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</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/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, </span></code><a href='#impl-FromParallelIterator%3C(K%2C%20V)%3E-for-HashMap%3CK%2C%20V%2C%20S%3E' class='anchor'></a><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#78-90' title='goto source code'>[src]</a></h3><div class='docblock'><p>Collect (key, value) pairs from a parallel iterator into a
|
|
|
|
|
hashmap. If multiple pairs correspond to the same key, then the
|
|
|
|
|
ones produced earlier in the parallel iterator will be
|
|
|
|
|
overwritten, just as with a sequential iterator.</p>
|
|
|
|
|
</div><div class='impl-items'><h4 id='method.from_par_iter-4' class="method hidden"><code id='from_par_iter.v-5'>fn <a href='#method.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self <span class="where fmt-newline">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><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>>, </span></code><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#84-89' title='goto source code'>[src]</a></h4></div><h3 id='impl-FromParallelIterator%3C(K%2C%20V)%3E-for-BTreeMap%3CK%2C%20V%3E' class='impl'><code class='in-band'>impl<K, V> <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><<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>> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/btree/map/struct.BTreeMap.html" title="struct alloc::collections::btree::map::BTreeMap">BTreeMap</a><K, V> <span class="where fmt-newline">where<br> K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,<br> V: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, </span></code><a href='#impl-FromParallelIterator%3C(K%2C%20V)%3E-for-BTreeMap%3CK%2C%20V%3E' class='anchor'></a><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#96-107' title='goto source code'>[src]</a></h3><div class='docblock'><p>Collect (key, value) pairs from a parallel iterator into a
|
|
|
|
|
btreemap. If multiple pairs correspond to the same key, then the
|
|
|
|
|
ones produced earlier in the parallel iterator will be
|
|
|
|
|
overwritten, just as with a sequential iterator.</p>
|
|
|
|
|
</div><div class='impl-items'><h4 id='method.from_par_iter-5' class="method hidden"><code id='from_par_iter.v-6'>fn <a href='#method.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self <span class="where fmt-newline">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><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>>, </span></code><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#101-106' title='goto source code'>[src]</a></h4></div><h3 id='impl-FromParallelIterator%3CV%3E-for-HashSet%3CV%2C%20S%3E' class='impl'><code class='in-band'>impl<V, S> <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><V> for <a class="struct" href="https://doc.rust-lang.org/nightly/std/collections/hash/set/struct.HashSet.html" title="struct std::collections::hash::set::HashSet">HashSet</a><V, S> <span class="where fmt-newline">where<br> 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> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,<br> S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.BuildHasher.html" title="trait core::hash::BuildHasher">BuildHasher</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/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, </span></code><a href='#impl-FromParallelIterator%3CV%3E-for-HashSet%3CV%2C%20S%3E' class='anchor'></a><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#110-121' title='goto source code'>[src]</a></h3><div class='docblock'><p>Collect values from a parallel iterator into a hashset.</p>
|
|
|
|
|
</div><div class='impl-items'><h4 id='method.from_par_iter-6' class="method hidden"><code id='from_par_iter.v-7'>fn <a href='#method.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self <span class="where fmt-newline">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><Item = V>, </span></code><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#115-120' title='goto source code'>[src]</a></h4></div><h3 id='impl-FromParallelIterator%3CV%3E-for-BTreeSet%3CV%3E' class='impl'><code class='in-band'>impl<V> <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><V> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/collections/btree/set/struct.BTreeSet.html" title="struct alloc::collections::btree::set::BTreeSet">BTreeSet</a><V> <span class="where fmt-newline">where<br> V: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a>, </span></code><a href='#impl-FromParallelIterator%3CV%3E-for-BTreeSet%3CV%3E' class='anchor'></a><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#124-134' title='goto source code'>[src]</a></h3><div class='docblock'><p>Collect values from a parallel iterator into a btreeset.</p>
|
|
|
|
|
</div><div class='impl-items'><h4 id='method.from_par_iter-7' class="method hidden"><code id='from_par_iter.v-8'>fn <a href='#method.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self <span class="where fmt-newline">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><Item = V>, </span></code><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#128-133' title='goto source code'>[src]</a></h4></div><h3 id='impl-FromParallelIterator%3Cchar%3E-for-String' class='impl'><code class='in-band'>impl <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.char.html">char</a>> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code><a href='#impl-FromParallelIterator%3Cchar%3E-for-String' class='anchor'></a><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#137-144' title='goto source code'>[src]</a></h3><div class='docblock'><p>Collect characters from a parallel iterator into a string.</p>
|
|
|
|
|
</div><div class='impl-items'><h4 id='method.from_par_iter-8' class="method hidden"><code id='from_par_iter.v-9'>fn <a href='#method.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self <span class="where fmt-newline">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><Item = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.char.html">char</a>>, </span></code><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#138-143' title='goto source code'>[src]</a></h4></div><h3 id='impl-FromParallelIterator%3C%26%27a%20char%3E-for-String' class='impl'><code class='in-band'>impl<'a> <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><&'a <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.char.html">char</a>> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code><a href='#impl-FromParallelIterator%3C%26%27a%20char%3E-for-String' class='anchor'></a><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#147-154' title='goto source code'>[src]</a></h3><div class='docblock'><p>Collect characters from a parallel iterator into a string.</p>
|
|
|
|
|
</div><div class='impl-items'><h4 id='method.from_par_iter-9' class="method hidden"><code id='from_par_iter.v-10'>fn <a href='#method.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self <span class="where fmt-newline">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><Item = &'a <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.char.html">char</a>>, </span></code><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#148-153' title='goto source code'>[src]</a></h4></div><h3 id='impl-FromParallelIterator%3C%26%27a%20str%3E-for-String' class='impl'><code class='in-band'>impl<'a> <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><&'a <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code><a href='#impl-FromParallelIterator%3C%26%27a%20str%3E-for-String' class='anchor'></a><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#157-164' title='goto source code'>[src]</a></h3><div class='docblock'><p>Collect string slices from a parallel iterator into a string.</p>
|
|
|
|
|
</div><div class='impl-items'><h4 id='method.from_par_iter-10' class="method hidden"><code id='from_par_iter.v-11'>fn <a href='#method.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self <span class="where fmt-newline">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><Item = &'a <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>, </span></code><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#158-163' title='goto source code'>[src]</a></h4></div><h3 id='impl-FromParallelIterator%3CString%3E-for-String' class='impl'><code class='in-band'>impl <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code><a href='#impl-FromParallelIterator%3CString%3E-for-String' class='anchor'></a><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#167-174' title='goto source code'>[src]</a></h3><div class='docblock'><p>Collect strings from a parallel iterator into one large string.</p>
|
|
|
|
|
</div><div class='impl-items'><h4 id='method.from_par_iter-11' class="method hidden"><code id='from_par_iter.v-12'>fn <a href='#method.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self <span class="where fmt-newline">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><Item = <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>>, </span></code><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#168-173' title='goto source code'>[src]</a></h4></div><h3 id='impl-FromParallelIterator%3CCow%3C%27a%2C%20str%3E%3E-for-String' class='impl'><code class='in-band'>impl<'a> <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><<a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a><'a, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>> for <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code><a href='#impl-FromParallelIterator%3CCow%3C%27a%2C%20str%3E%3E-for-String' class='anchor'></a><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#177-184' title='goto source code'>[src]</a></h3><div class='docblock'><p>Collect string slices from a parallel iterator into a string.</p>
|
|
|
|
|
</div><div class='impl-items'><h4 id='method.from_par_iter-12' class="method hidden"><code id='from_par_iter.v-13'>fn <a href='#method.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self <span class="where fmt-newline">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><Item = <a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a><'a, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>>>, </span></code><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#178-183' title='goto source code'>[src]</a></h4></div><h3 id='impl-FromParallelIterator%3CT%3E-for-Cow%3C%27a%2C%20C%3E' class='impl'><code class='in-band'>impl<'a, C: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, T> <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><T> for <a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a><'a, C> <span class="where fmt-newline">where<br> C: <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a>,<br> C::<a class="type" href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" title="type alloc::borrow::ToOwned::Owned">Owned</a>: <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><T>,<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, </span></code><a href='#impl-FromParallelIterator%3CT%3E-for-Cow%3C%27a%2C%20C%3E' class='anchor'></a><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#191-203' title='goto source code'>[src]</a></h3><div class='docblock'><p>Collect an arbitrary <code>Cow</code> collection.</p>
|
|
|
|
|
<p>Note, the standard library only has <code>FromIterator</code> for <code>Cow<'a, str></code> and
|
|
|
|
|
<code>Cow<'a, [T]></code>, because no one thought to add a blanket implementation
|
|
|
|
|
before it was stabilized.</p>
|
|
|
|
|
</div><div class='impl-items'><h4 id='method.from_par_iter-13' class="method hidden"><code id='from_par_iter.v-14'>fn <a href='#method.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self <span class="where fmt-newline">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><Item = T>, </span></code><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#197-202' title='goto source code'>[src]</a></h4></div><h3 id='impl-FromParallelIterator%3C()%3E-for-()' class='impl'><code class='in-band'>impl <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a></code><a href='#impl-FromParallelIterator%3C()%3E-for-()' class='anchor'></a><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#220-227' title='goto source code'>[src]</a></h3><div class='docblock'><p>Collapses all unit items from a parallel iterator into one.</p>
|
|
|
|
|
<p>This is more useful when combined with higher-level abstractions, like
|
|
|
|
|
collecting to a <code>Result<(), E></code> where you only care about errors:</p>
|
|
|
|
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
|
|
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="kw-2">*</span>;
|
|
|
|
|
<span class="kw">use</span> <span class="ident">rayon</span>::<span class="ident">prelude</span>::<span class="kw-2">*</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">4</span>, <span class="number">5</span>];
|
|
|
|
|
<span class="kw">let</span> <span class="ident">res</span>: <span class="prelude-ty">Result</span><span class="op"><</span>()<span class="op">></span> <span class="op">=</span> <span class="ident">data</span>.<span class="ident">par_iter</span>()
|
|
|
|
|
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">x</span><span class="op">|</span> <span class="macro">writeln</span><span class="macro">!</span>(<span class="ident">stdout</span>(), <span class="string">"{}"</span>, <span class="ident">x</span>))
|
|
|
|
|
.<span class="ident">collect</span>();
|
|
|
|
|
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">res</span>.<span class="ident">is_ok</span>());</pre></div>
|
|
|
|
|
</div><div class='impl-items'><h4 id='method.from_par_iter-14' class="method hidden"><code id='from_par_iter.v-15'>fn <a href='#method.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self <span class="where fmt-newline">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><Item = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>>, </span></code><a class='srclink' href='../../src/rayon/iter/from_par_iter.rs.html#221-226' title='goto source code'>[src]</a></h4></div><h3 id='impl-FromParallelIterator%3COption%3CT%3E%3E-for-Option%3CC%3E' class='impl'><code class='in-band'>impl<C, T> <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><T>> for <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><C> <span class="where fmt-newline">where<br> C: <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><T>,<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, </span></code><a href='#impl-FromParallelIterator%3COption%3CT%3E%3E-for-Option%3CC%3E' class='anchor'></a><a class='srclink' href='../../src/rayon/option.rs.html#174-200' title='goto source code'>[src]</a></h3><div class='docblock'><p>Collect an arbitrary <code>Option</code>-wrapped collection.</p>
|
|
|
|
|
<p>If any item is <code>None</code>, then all previous items collected are discarded,
|
|
|
|
|
and it returns only <code>None</code>.</p>
|
|
|
|
|
</div><div class='impl-items'><h4 id='method.from_par_iter-15' class="method hidden"><code id='from_par_iter.v-16'>fn <a href='#method.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self <span class="where fmt-newline">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><Item = <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><T>>, </span></code><a class='srclink' href='../../src/rayon/option.rs.html#179-199' title='goto source code'>[src]</a></h4></div><h3 id='impl-FromParallelIterator%3CResult%3CT%2C%20E%3E%3E-for-Result%3CC%2C%20E%3E' class='impl'><code class='in-band'>impl<C, T, E> <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><<a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, E>> for <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><C, E> <span class="where fmt-newline">where<br> C: <a class="trait" href="../../rayon/iter/trait.FromParallelIterator.html" title="trait rayon::iter::FromParallelIterator">FromParallelIterator</a><T>,<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,<br> E: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>, </span></code><a href='#impl-FromParallelIterator%3CResult%3CT%2C%20E%3E%3E-for-Result%3CC%2C%20E%3E' class='anchor'></a><a class='srclink' href='../../src/rayon/result.rs.html#93-128' title='goto source code'>[src]</a></h3><div class='docblock'><p>Collect an arbitrary <code>Result</code>-wrapped collection.</p>
|
|
|
|
|
<p>If any item is <code>Err</code>, then all previous <code>Ok</code> items collected are
|
|
|
|
|
discarded, and it returns that error. If there are multiple errors, the
|
|
|
|
|
one returned is not deterministic.</p>
|
|
|
|
|
</div><div class='impl-items'><h4 id='method.from_par_iter-16' class="method hidden"><code id='from_par_iter.v-17'>fn <a href='#method.from_par_iter' class='fnname'>from_par_iter</a><I>(par_iter: I) -> Self <span class="where fmt-newline">where<br> I: <a class="trait" href="../../rayon/iter/trait.IntoParallelIterator.html" title="trait rayon::iter::IntoParallelIterator">IntoParallelIterator</a><Item = <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, E>>, </span></code><a class='srclink' href='../../src/rayon/result.rs.html#99-127' title='goto source code'>[src]</a></h4></div><span class='loading-content'>Loading content...</span>
|
|
|
|
|
<h2 id='implementors' class='small-section-header'>Implementors<a href='#implementors' class='anchor'></a></h2><div class='item-list' id='implementors-list'></div><span class='loading-content'>Loading content...</span><script type="text/javascript">window.inlined_types=new Set([]);</script><script type="text/javascript" async
|
|
|
|
|
src="../../implementors/rayon/iter/trait.FromParallelIterator.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>⏎</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><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../../";window.currentCrate = "rayon";</script><script src="../../aliases.js"></script><script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|