|
|
|
|
<!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 `ParallelString` trait in crate `rayon`."><meta name="keywords" content="rust, rustlang, rust-lang, ParallelString"><title>rayon::str::ParallelString - 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 ParallelString</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.as_parallel_string">as_parallel_string</a></div><a class="sidebar-title" href="#provided-methods">Provided Methods</a><div class="sidebar-links"><a href="#method.par_bytes">par_bytes</a><a href="#method.par_char_indices">par_char_indices</a><a href="#method.par_chars">par_chars</a><a href="#method.par_encode_utf16">par_encode_utf16</a><a href="#method.par_lines">par_lines</a><a href="#method.par_match_indices">par_match_indices</a><a href="#method.par_matches">par_matches</a><a href="#method.par_split">par_split</a><a href="#method.par_split_terminator">par_split_terminator</a><a href="#method.par_split_whitespace">par_split_whitespace</a></div><a class="sidebar-title" href="#foreign-impls">Implementations on Foreign Types</a><div class="sidebar-links"><a href="#impl-ParallelString-for-str">str</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'>str</a></p><script>window.sidebarCurrent = {name: 'ParallelString', 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="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><span class='out-of-band'><span id='render-detail'><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class='inner'>−</span>]</a></span><a class='srclink' href='../../src/rayon/str.rs.html#59-261' title='goto source code'>[src]</a></span><span class='in-band'>Trait <a href='../index.html'>rayon</a>::<wbr><a href='index.html'>str</a>::<wbr><a class="trait" href=''>ParallelString</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust trait'>pub trait ParallelString {
|
|
|
|
|
fn <a href='#tymethod.as_parallel_string' class='fnname'>as_parallel_string</a>(&self) -> &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>;
|
|
|
|
|
|
|
|
|
|
fn <a href='#method.par_chars' class='fnname'>par_chars</a>(&self) -> <a class="struct" href="../../rayon/str/struct.Chars.html" title="struct rayon::str::Chars">Chars</a> { ... }
|
|
|
|
|
<div class='item-spacer'></div> fn <a href='#method.par_char_indices' class='fnname'>par_char_indices</a>(&self) -> <a class="struct" href="../../rayon/str/struct.CharIndices.html" title="struct rayon::str::CharIndices">CharIndices</a> { ... }
|
|
|
|
|
<div class='item-spacer'></div> fn <a href='#method.par_bytes' class='fnname'>par_bytes</a>(&self) -> <a class="struct" href="../../rayon/str/struct.Bytes.html" title="struct rayon::str::Bytes">Bytes</a> { ... }
|
|
|
|
|
<div class='item-spacer'></div> fn <a href='#method.par_encode_utf16' class='fnname'>par_encode_utf16</a>(&self) -> <a class="struct" href="../../rayon/str/struct.EncodeUtf16.html" title="struct rayon::str::EncodeUtf16">EncodeUtf16</a> { ... }
|
|
|
|
|
<div class='item-spacer'></div> fn <a href='#method.par_split' class='fnname'>par_split</a><P: Pattern>(&self, separator: P) -> <a class="struct" href="../../rayon/str/struct.Split.html" title="struct rayon::str::Split">Split</a><P> { ... }
|
|
|
|
|
<div class='item-spacer'></div> fn <a href='#method.par_split_terminator' class='fnname'>par_split_terminator</a><P: Pattern>(<br> &self, <br> terminator: P<br> ) -> <a class="struct" href="../../rayon/str/struct.SplitTerminator.html" title="struct rayon::str::SplitTerminator">SplitTerminator</a><P> { ... }
|
|
|
|
|
<div class='item-spacer'></div> fn <a href='#method.par_lines' class='fnname'>par_lines</a>(&self) -> <a class="struct" href="../../rayon/str/struct.Lines.html" title="struct rayon::str::Lines">Lines</a> { ... }
|
|
|
|
|
<div class='item-spacer'></div> fn <a href='#method.par_split_whitespace' class='fnname'>par_split_whitespace</a>(&self) -> <a class="struct" href="../../rayon/str/struct.SplitWhitespace.html" title="struct rayon::str::SplitWhitespace">SplitWhitespace</a> { ... }
|
|
|
|
|
<div class='item-spacer'></div> fn <a href='#method.par_matches' class='fnname'>par_matches</a><P: Pattern>(&self, pattern: P) -> <a class="struct" href="../../rayon/str/struct.Matches.html" title="struct rayon::str::Matches">Matches</a><P> { ... }
|
|
|
|
|
<div class='item-spacer'></div> fn <a href='#method.par_match_indices' class='fnname'>par_match_indices</a><P: Pattern>(&self, pattern: P) -> <a class="struct" href="../../rayon/str/struct.MatchIndices.html" title="struct rayon::str::MatchIndices">MatchIndices</a><P> { ... }
|
|
|
|
|
}</pre></div><div class='docblock'><p>Parallel extensions for strings.</p>
|
|
|
|
|
</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.as_parallel_string' class='method'><code id='as_parallel_string.v'>fn <a href='#tymethod.as_parallel_string' class='fnname'>as_parallel_string</a>(&self) -> &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code></h3><div class='docblock'><p>Returns a plain string slice, which is used to implement the rest of
|
|
|
|
|
the parallel methods.</p>
|
|
|
|
|
</div></div><span class='loading-content'>Loading content...</span>
|
|
|
|
|
<h2 id='provided-methods' class='small-section-header'>Provided methods<a href='#provided-methods' class='anchor'></a></h2><div class='methods'><h3 id='method.par_chars' class='method'><code id='par_chars.v'>fn <a href='#method.par_chars' class='fnname'>par_chars</a>(&self) -> <a class="struct" href="../../rayon/str/struct.Chars.html" title="struct rayon::str::Chars">Chars</a></code></h3><div class='docblock'><p>Returns a parallel iterator over the characters of a string.</p>
|
|
|
|
|
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
|
|
|
|
<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">let</span> <span class="ident">max</span> <span class="op">=</span> <span class="string">"hello"</span>.<span class="ident">par_chars</span>().<span class="ident">max_by_key</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="kw-2">*</span><span class="ident">c</span> <span class="kw">as</span> <span class="ident">i32</span>);
|
|
|
|
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="string">'o'</span>), <span class="ident">max</span>);</pre></div>
|
|
|
|
|
</div><h3 id='method.par_char_indices' class='method'><code id='par_char_indices.v'>fn <a href='#method.par_char_indices' class='fnname'>par_char_indices</a>(&self) -> <a class="struct" href="../../rayon/str/struct.CharIndices.html" title="struct rayon::str::CharIndices">CharIndices</a></code></h3><div class='docblock'><p>Returns a parallel iterator over the characters of a string, with their positions.</p>
|
|
|
|
|
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
|
|
|
|
<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">let</span> <span class="ident">min</span> <span class="op">=</span> <span class="string">"hello"</span>.<span class="ident">par_char_indices</span>().<span class="ident">min_by_key</span>(<span class="op">|</span><span class="kw-2">&</span>(<span class="ident">_i</span>, <span class="ident">c</span>)<span class="op">|</span> <span class="ident">c</span> <span class="kw">as</span> <span class="ident">i32</span>);
|
|
|
|
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>((<span class="number">1</span>, <span class="string">'e'</span>)), <span class="ident">min</span>);</pre></div>
|
|
|
|
|
</div><h3 id='method.par_bytes' class='method'><code id='par_bytes.v'>fn <a href='#method.par_bytes' class='fnname'>par_bytes</a>(&self) -> <a class="struct" href="../../rayon/str/struct.Bytes.html" title="struct rayon::str::Bytes">Bytes</a></code></h3><div class='docblock'><p>Returns a parallel iterator over the bytes of a string.</p>
|
|
|
|
|
<p>Note that multi-byte sequences (for code points greater than <code>U+007F</code>)
|
|
|
|
|
are produced as separate items, but will not be split across threads.
|
|
|
|
|
If you would prefer an indexed iterator without that guarantee, consider
|
|
|
|
|
<code>string.as_bytes().par_iter().cloned()</code> instead.</p>
|
|
|
|
|
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
|
|
|
|
|
<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">let</span> <span class="ident">max</span> <span class="op">=</span> <span class="string">"hello"</span>.<span class="ident">par_bytes</span>().<span class="ident">max</span>();
|
|
|
|
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="string">b'o'</span>), <span class="ident">max</span>);</pre></div>
|
|
|
|
|
</div><h3 id='method.par_encode_utf16' class='method'><code id='par_encode_utf16.v'>fn <a href='#method.par_encode_utf16' class='fnname'>par_encode_utf16</a>(&self) -> <a class="struct" href="../../rayon/str/struct.EncodeUtf16.html" title="struct rayon::str::EncodeUtf16">EncodeUtf16</a></code></h3><div class='docblock'><p>Returns a parallel iterator over a string encoded as UTF-16.</p>
|
|
|
|
|
<p>Note that surrogate pairs (for code points greater than <code>U+FFFF</code>) are
|
|
|
|
|
produced as separate items, but will not be split across threads.</p>
|
|
|
|
|
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
|
|
|
|
|
<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">let</span> <span class="ident">max</span> <span class="op">=</span> <span class="string">"hello"</span>.<span class="ident">par_encode_utf16</span>().<span class="ident">max</span>();
|
|
|
|
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="string">b'o'</span> <span class="kw">as</span> <span class="ident">u16</span>), <span class="ident">max</span>);
|
|
|
|
|
|
|
|
|
|
<span class="kw">let</span> <span class="ident">text</span> <span class="op">=</span> <span class="string">"Zażółć gęślą jaźń"</span>;
|
|
|
|
|
<span class="kw">let</span> <span class="ident">utf8_len</span> <span class="op">=</span> <span class="ident">text</span>.<span class="ident">len</span>();
|
|
|
|
|
<span class="kw">let</span> <span class="ident">utf16_len</span> <span class="op">=</span> <span class="ident">text</span>.<span class="ident">par_encode_utf16</span>().<span class="ident">count</span>();
|
|
|
|
|
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">utf16_len</span> <span class="op"><</span><span class="op">=</span> <span class="ident">utf8_len</span>);</pre></div>
|
|
|
|
|
</div><h3 id='method.par_split' class='method'><code id='par_split.v'>fn <a href='#method.par_split' class='fnname'>par_split</a><P: Pattern>(&self, separator: P) -> <a class="struct" href="../../rayon/str/struct.Split.html" title="struct rayon::str::Split">Split</a><P></code></h3><div class='docblock'><p>Returns a parallel iterator over substrings separated by a
|
|
|
|
|
given character or predicate, similar to <code>str::split</code>.</p>
|
|
|
|
|
<p>Note: the <code>Pattern</code> trait is private, for use only by Rayon itself.
|
|
|
|
|
It is implemented for <code>char</code> and any <code>F: Fn(char) -> bool + Sync + Send</code>.</p>
|
|
|
|
|
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
|
|
|
|
|
<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">let</span> <span class="ident">total</span> <span class="op">=</span> <span class="string">"1, 2, buckle, 3, 4, door"</span>
|
|
|
|
|
.<span class="ident">par_split</span>(<span class="string">','</span>)
|
|
|
|
|
.<span class="ident">filter_map</span>(<span class="op">|</span><span class="ident">s</span><span class="op">|</span> <span class="ident">s</span>.<span class="ident">trim</span>().<span class="ident">parse</span>::<span class="op"><</span><span class="ident">i32</span><span class="op">></span>().<span class="ident">ok</span>())
|
|
|
|
|
.<span class="ident">sum</span>();
|
|
|
|
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">10</span>, <span class="ident">total</span>);</pre></div>
|
|
|
|
|
</div><h3 id='method.par_split_terminator' class='method'><code id='par_split_terminator.v'>fn <a href='#method.par_split_terminator' class='fnname'>par_split_terminator</a><P: Pattern>(&self, terminator: P) -> <a class="struct" href="../../rayon/str/struct.SplitTerminator.html" title="struct rayon::str::SplitTerminator">SplitTerminator</a><P></code></h3><div class='docblock'><p>Returns a parallel iterator over substrings terminated by a
|
|
|
|
|
given character or predicate, similar to <code>str::split_terminator</code>.
|
|
|
|
|
It's equivalent to <code>par_split</code>, except it doesn't produce an empty
|
|
|
|
|
substring after a trailing terminator.</p>
|
|
|
|
|
<p>Note: the <code>Pattern</code> trait is private, for use only by Rayon itself.
|
|
|
|
|
It is implemented for <code>char</code> and any <code>F: Fn(char) -> bool + Sync + Send</code>.</p>
|
|
|
|
|
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
|
|
|
|
|
<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">let</span> <span class="ident">parts</span>: <span class="ident">Vec</span><span class="op"><</span><span class="kw">_</span><span class="op">></span> <span class="op">=</span> <span class="string">"((1 + 3) * 2)"</span>
|
|
|
|
|
.<span class="ident">par_split_terminator</span>(<span class="op">|</span><span class="ident">c</span><span class="op">|</span> <span class="ident">c</span> <span class="op">=</span><span class="op">=</span> <span class="string">'('</span> <span class="op">|</span><span class="op">|</span> <span class="ident">c</span> <span class="op">=</span><span class="op">=</span> <span class="string">')'</span>)
|
|
|
|
|
.<span class="ident">collect</span>();
|
|
|
|
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="string">""</span>, <span class="string">""</span>, <span class="string">"1 + 3"</span>, <span class="string">" * 2"</span>], <span class="ident">parts</span>);</pre></div>
|
|
|
|
|
</div><h3 id='method.par_lines' class='method'><code id='par_lines.v'>fn <a href='#method.par_lines' class='fnname'>par_lines</a>(&self) -> <a class="struct" href="../../rayon/str/struct.Lines.html" title="struct rayon::str::Lines">Lines</a></code></h3><div class='docblock'><p>Returns a parallel iterator over the lines of a string, ending with an
|
|
|
|
|
optional carriage return and with a newline (<code>\r\n</code> or just <code>\n</code>).
|
|
|
|
|
The final line ending is optional, and line endings are not included in
|
|
|
|
|
the output strings.</p>
|
|
|
|
|
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
|
|
|
|
|
<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">let</span> <span class="ident">lengths</span>: <span class="ident">Vec</span><span class="op"><</span><span class="kw">_</span><span class="op">></span> <span class="op">=</span> <span class="string">"hello world\nfizbuzz"</span>
|
|
|
|
|
.<span class="ident">par_lines</span>()
|
|
|
|
|
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">l</span><span class="op">|</span> <span class="ident">l</span>.<span class="ident">len</span>())
|
|
|
|
|
.<span class="ident">collect</span>();
|
|
|
|
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">11</span>, <span class="number">7</span>], <span class="ident">lengths</span>);</pre></div>
|
|
|
|
|
</div><h3 id='method.par_split_whitespace' class='method'><code id='par_split_whitespace.v'>fn <a href='#method.par_split_whitespace' class='fnname'>par_split_whitespace</a>(&self) -> <a class="struct" href="../../rayon/str/struct.SplitWhitespace.html" title="struct rayon::str::SplitWhitespace">SplitWhitespace</a></code></h3><div class='docblock'><p>Returns a parallel iterator over the sub-slices of a string that are
|
|
|
|
|
separated by any amount of whitespace.</p>
|
|
|
|
|
<p>As with <code>str::split_whitespace</code>, 'whitespace' is defined according to
|
|
|
|
|
the terms of the Unicode Derived Core Property <code>White_Space</code>.</p>
|
|
|
|
|
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
|
|
|
|
|
<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">let</span> <span class="ident">longest</span> <span class="op">=</span> <span class="string">"which is the longest word?"</span>
|
|
|
|
|
.<span class="ident">par_split_whitespace</span>()
|
|
|
|
|
.<span class="ident">max_by_key</span>(<span class="op">|</span><span class="ident">word</span><span class="op">|</span> <span class="ident">word</span>.<span class="ident">len</span>());
|
|
|
|
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="string">"longest"</span>), <span class="ident">longest</span>);</pre></div>
|
|
|
|
|
</div><h3 id='method.par_matches' class='method'><code id='par_matches.v'>fn <a href='#method.par_matches' class='fnname'>par_matches</a><P: Pattern>(&self, pattern: P) -> <a class="struct" href="../../rayon/str/struct.Matches.html" title="struct rayon::str::Matches">Matches</a><P></code></h3><div class='docblock'><p>Returns a parallel iterator over substrings that match a
|
|
|
|
|
given character or predicate, similar to <code>str::matches</code>.</p>
|
|
|
|
|
<p>Note: the <code>Pattern</code> trait is private, for use only by Rayon itself.
|
|
|
|
|
It is implemented for <code>char</code> and any <code>F: Fn(char) -> bool + Sync + Send</code>.</p>
|
|
|
|
|
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
|
|
|
|
|
<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">let</span> <span class="ident">total</span> <span class="op">=</span> <span class="string">"1, 2, buckle, 3, 4, door"</span>
|
|
|
|
|
.<span class="ident">par_matches</span>(<span class="ident">char</span>::<span class="ident">is_numeric</span>)
|
|
|
|
|
.<span class="ident">map</span>(<span class="op">|</span><span class="ident">s</span><span class="op">|</span> <span class="ident">s</span>.<span class="ident">parse</span>::<span class="op"><</span><span class="ident">i32</span><span class="op">></span>().<span class="ident">expect</span>(<span class="string">"digit"</span>))
|
|
|
|
|
.<span class="ident">sum</span>();
|
|
|
|
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">10</span>, <span class="ident">total</span>);</pre></div>
|
|
|
|
|
</div><h3 id='method.par_match_indices' class='method'><code id='par_match_indices.v'>fn <a href='#method.par_match_indices' class='fnname'>par_match_indices</a><P: Pattern>(&self, pattern: P) -> <a class="struct" href="../../rayon/str/struct.MatchIndices.html" title="struct rayon::str::MatchIndices">MatchIndices</a><P></code></h3><div class='docblock'><p>Returns a parallel iterator over substrings that match a given character
|
|
|
|
|
or predicate, with their positions, similar to <code>str::match_indices</code>.</p>
|
|
|
|
|
<p>Note: the <code>Pattern</code> trait is private, for use only by Rayon itself.
|
|
|
|
|
It is implemented for <code>char</code> and any <code>F: Fn(char) -> bool + Sync + Send</code>.</p>
|
|
|
|
|
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
|
|
|
|
|
<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">let</span> <span class="ident">digits</span>: <span class="ident">Vec</span><span class="op"><</span><span class="kw">_</span><span class="op">></span> <span class="op">=</span> <span class="string">"1, 2, buckle, 3, 4, door"</span>
|
|
|
|
|
.<span class="ident">par_match_indices</span>(<span class="ident">char</span>::<span class="ident">is_numeric</span>)
|
|
|
|
|
.<span class="ident">collect</span>();
|
|
|
|
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">digits</span>, <span class="macro">vec</span><span class="macro">!</span>[(<span class="number">0</span>, <span class="string">"1"</span>), (<span class="number">3</span>, <span class="string">"2"</span>), (<span class="number">14</span>, <span class="string">"3"</span>), (<span class="number">17</span>, <span class="string">"4"</span>)]);</pre></div>
|
|
|
|
|
</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-ParallelString-for-str' class='impl'><code class='in-band'>impl <a class="trait" href="../../rayon/str/trait.ParallelString.html" title="trait rayon::str::ParallelString">ParallelString</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><a href='#impl-ParallelString-for-str' class='anchor'></a><a class='srclink' href='../../src/rayon/str.rs.html#263-268' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='method.as_parallel_string' class="method hidden"><code id='as_parallel_string.v-1'>fn <a href='#method.as_parallel_string' class='fnname'>as_parallel_string</a>(&self) -> &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><a class='srclink' href='../../src/rayon/str.rs.html#265-267' 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/str/trait.ParallelString.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>
|