Files
GopherGate/target/doc/rayon/str/trait.ParallelString.html
2026-02-26 12:00:21 -05:00

167 lines
30 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!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 strings."><title>ParallelString in rayon::str - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="rayon" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">ParallelString</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../rayon/index.html">rayon</a><span class="version">1.11.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Parallel<wbr>String</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.as_parallel_string" title="as_parallel_string">as_parallel_string</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.par_bytes" title="par_bytes">par_bytes</a></li><li><a href="#method.par_char_indices" title="par_char_indices">par_char_indices</a></li><li><a href="#method.par_chars" title="par_chars">par_chars</a></li><li><a href="#method.par_encode_utf16" title="par_encode_utf16">par_encode_utf16</a></li><li><a href="#method.par_lines" title="par_lines">par_lines</a></li><li><a href="#method.par_match_indices" title="par_match_indices">par_match_indices</a></li><li><a href="#method.par_matches" title="par_matches">par_matches</a></li><li><a href="#method.par_split" title="par_split">par_split</a></li><li><a href="#method.par_split_ascii_whitespace" title="par_split_ascii_whitespace">par_split_ascii_whitespace</a></li><li><a href="#method.par_split_inclusive" title="par_split_inclusive">par_split_inclusive</a></li><li><a href="#method.par_split_terminator" title="par_split_terminator">par_split_terminator</a></li><li><a href="#method.par_split_whitespace" title="par_split_whitespace">par_split_whitespace</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-ParallelString-for-str" title="str">str</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In rayon::<wbr>str</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">rayon</a>::<wbr><a href="index.html">str</a></div><h1>Trait <span class="trait">Parallel<wbr>String</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/rayon/str.rs.html#58-342">Source</a> </span></div><pre class="rust item-decl"><code>pub trait ParallelString {
<details class="toggle type-contents-toggle"><summary class="hideme"><span>Show 13 methods</span></summary> // Required method
fn <a href="#tymethod.as_parallel_string" class="fn">as_parallel_string</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.str.html">str</a>;
// Provided methods
fn <a href="#method.par_chars" class="fn">par_chars</a>(&amp;self) -&gt; <a class="struct" href="struct.Chars.html" title="struct rayon::str::Chars">Chars</a>&lt;'_&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.par_char_indices" class="fn">par_char_indices</a>(&amp;self) -&gt; <a class="struct" href="struct.CharIndices.html" title="struct rayon::str::CharIndices">CharIndices</a>&lt;'_&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.par_bytes" class="fn">par_bytes</a>(&amp;self) -&gt; <a class="struct" href="struct.Bytes.html" title="struct rayon::str::Bytes">Bytes</a>&lt;'_&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.par_encode_utf16" class="fn">par_encode_utf16</a>(&amp;self) -&gt; <a class="struct" href="struct.EncodeUtf16.html" title="struct rayon::str::EncodeUtf16">EncodeUtf16</a>&lt;'_&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.par_split" class="fn">par_split</a>&lt;P: Pattern&gt;(&amp;self, separator: P) -&gt; <a class="struct" href="struct.Split.html" title="struct rayon::str::Split">Split</a>&lt;'_, P&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.par_split_inclusive" class="fn">par_split_inclusive</a>&lt;P: Pattern&gt;(
&amp;self,
separator: P,
) -&gt; <a class="struct" href="struct.SplitInclusive.html" title="struct rayon::str::SplitInclusive">SplitInclusive</a>&lt;'_, P&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.par_split_terminator" class="fn">par_split_terminator</a>&lt;P: Pattern&gt;(
&amp;self,
terminator: P,
) -&gt; <a class="struct" href="struct.SplitTerminator.html" title="struct rayon::str::SplitTerminator">SplitTerminator</a>&lt;'_, P&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.par_lines" class="fn">par_lines</a>(&amp;self) -&gt; <a class="struct" href="struct.Lines.html" title="struct rayon::str::Lines">Lines</a>&lt;'_&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.par_split_whitespace" class="fn">par_split_whitespace</a>(&amp;self) -&gt; <a class="struct" href="struct.SplitWhitespace.html" title="struct rayon::str::SplitWhitespace">SplitWhitespace</a>&lt;'_&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.par_split_ascii_whitespace" class="fn">par_split_ascii_whitespace</a>(&amp;self) -&gt; <a class="struct" href="struct.SplitAsciiWhitespace.html" title="struct rayon::str::SplitAsciiWhitespace">SplitAsciiWhitespace</a>&lt;'_&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.par_matches" class="fn">par_matches</a>&lt;P: Pattern&gt;(&amp;self, pattern: P) -&gt; <a class="struct" href="struct.Matches.html" title="struct rayon::str::Matches">Matches</a>&lt;'_, P&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.par_match_indices" class="fn">par_match_indices</a>&lt;P: Pattern&gt;(&amp;self, pattern: P) -&gt; <a class="struct" href="struct.MatchIndices.html" title="struct rayon::str::MatchIndices">MatchIndices</a>&lt;'_, P&gt; { ... }
</details>}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Parallel extensions for strings.</p>
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.as_parallel_string" class="method"><a class="src rightside" href="../../src/rayon/str.rs.html#61">Source</a><h4 class="code-header">fn <a href="#tymethod.as_parallel_string" class="fn">as_parallel_string</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.str.html">str</a></h4></section></summary><div class="docblock"><p>Returns a plain string slice, which is used to implement the rest of
the parallel methods.</p>
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.par_chars" class="method"><a class="src rightside" href="../../src/rayon/str.rs.html#72-76">Source</a><h4 class="code-header">fn <a href="#method.par_chars" class="fn">par_chars</a>(&amp;self) -&gt; <a class="struct" href="struct.Chars.html" title="struct rayon::str::Chars">Chars</a>&lt;'_&gt;</h4></section></summary><div class="docblock"><p>Returns a parallel iterator over the characters of a string.</p>
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rayon::prelude::<span class="kw-2">*</span>;
<span class="kw">let </span>max = <span class="string">"hello"</span>.par_chars().max_by_key(|c| <span class="kw-2">*</span>c <span class="kw">as </span>i32);
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="string">'o'</span>), max);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.par_char_indices" class="method"><a class="src rightside" href="../../src/rayon/str.rs.html#87-91">Source</a><h4 class="code-header">fn <a href="#method.par_char_indices" class="fn">par_char_indices</a>(&amp;self) -&gt; <a class="struct" href="struct.CharIndices.html" title="struct rayon::str::CharIndices">CharIndices</a>&lt;'_&gt;</h4></section></summary><div class="docblock"><p>Returns a parallel iterator over the characters of a string, with their positions.</p>
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rayon::prelude::<span class="kw-2">*</span>;
<span class="kw">let </span>min = <span class="string">"hello"</span>.par_char_indices().min_by_key(|<span class="kw-2">&amp;</span>(_i, c)| c <span class="kw">as </span>i32);
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>((<span class="number">1</span>, <span class="string">'e'</span>)), min);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.par_bytes" class="method"><a class="src rightside" href="../../src/rayon/str.rs.html#107-111">Source</a><h4 class="code-header">fn <a href="#method.par_bytes" class="fn">par_bytes</a>(&amp;self) -&gt; <a class="struct" href="struct.Bytes.html" title="struct rayon::str::Bytes">Bytes</a>&lt;'_&gt;</h4></section></summary><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().copied()</code> instead.</p>
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rayon::prelude::<span class="kw-2">*</span>;
<span class="kw">let </span>max = <span class="string">"hello"</span>.par_bytes().max();
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="string">b'o'</span>), max);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.par_encode_utf16" class="method"><a class="src rightside" href="../../src/rayon/str.rs.html#131-135">Source</a><h4 class="code-header">fn <a href="#method.par_encode_utf16" class="fn">par_encode_utf16</a>(&amp;self) -&gt; <a class="struct" href="struct.EncodeUtf16.html" title="struct rayon::str::EncodeUtf16">EncodeUtf16</a>&lt;'_&gt;</h4></section></summary><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>
<h5 id="examples-3"><a class="doc-anchor" href="#examples-3">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rayon::prelude::<span class="kw-2">*</span>;
<span class="kw">let </span>max = <span class="string">"hello"</span>.par_encode_utf16().max();
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="string">b'o' </span><span class="kw">as </span>u16), max);
<span class="kw">let </span>text = <span class="string">"Zażółć gęślą jaźń"</span>;
<span class="kw">let </span>utf8_len = text.len();
<span class="kw">let </span>utf16_len = text.par_encode_utf16().count();
<span class="macro">assert!</span>(utf16_len &lt;= utf8_len);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.par_split" class="method"><a class="src rightside" href="../../src/rayon/str.rs.html#154-156">Source</a><h4 class="code-header">fn <a href="#method.par_split" class="fn">par_split</a>&lt;P: Pattern&gt;(&amp;self, separator: P) -&gt; <a class="struct" href="struct.Split.html" title="struct rayon::str::Split">Split</a>&lt;'_, P&gt;</h4></section></summary><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>, <code>&amp;[char]</code>, <code>[char; N]</code>, <code>&amp;[char; N]</code>,
and any function or closure <code>F: Fn(char) -&gt; bool + Sync + Send</code>.</p>
<h5 id="examples-4"><a class="doc-anchor" href="#examples-4">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rayon::prelude::<span class="kw-2">*</span>;
<span class="kw">let </span>total = <span class="string">"1, 2, buckle, 3, 4, door"
</span>.par_split(<span class="string">','</span>)
.filter_map(|s| s.trim().parse::&lt;i32&gt;().ok())
.sum();
<span class="macro">assert_eq!</span>(<span class="number">10</span>, total);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.par_split_inclusive" class="method"><a class="src rightside" href="../../src/rayon/str.rs.html#175-177">Source</a><h4 class="code-header">fn <a href="#method.par_split_inclusive" class="fn">par_split_inclusive</a>&lt;P: Pattern&gt;(&amp;self, separator: P) -&gt; <a class="struct" href="struct.SplitInclusive.html" title="struct rayon::str::SplitInclusive">SplitInclusive</a>&lt;'_, P&gt;</h4></section></summary><div class="docblock"><p>Returns a parallel iterator over substrings separated by a
given character or predicate, keeping the matched part as a terminator
of the substring similar to <code>str::split_inclusive</code>.</p>
<p>Note: the <code>Pattern</code> trait is private, for use only by Rayon itself.
It is implemented for <code>char</code>, <code>&amp;[char]</code>, <code>[char; N]</code>, <code>&amp;[char; N]</code>,
and any function or closure <code>F: Fn(char) -&gt; bool + Sync + Send</code>.</p>
<h5 id="examples-5"><a class="doc-anchor" href="#examples-5">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rayon::prelude::<span class="kw-2">*</span>;
<span class="kw">let </span>lines: Vec&lt;<span class="kw">_</span>&gt; = <span class="string">"Mary had a little lamb\nlittle lamb\nlittle lamb."
</span>.par_split_inclusive(<span class="string">'\n'</span>)
.collect();
<span class="macro">assert_eq!</span>(lines, [<span class="string">"Mary had a little lamb\n"</span>, <span class="string">"little lamb\n"</span>, <span class="string">"little lamb."</span>]);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.par_split_terminator" class="method"><a class="src rightside" href="../../src/rayon/str.rs.html#197-199">Source</a><h4 class="code-header">fn <a href="#method.par_split_terminator" class="fn">par_split_terminator</a>&lt;P: Pattern&gt;(
&amp;self,
terminator: P,
) -&gt; <a class="struct" href="struct.SplitTerminator.html" title="struct rayon::str::SplitTerminator">SplitTerminator</a>&lt;'_, P&gt;</h4></section></summary><div class="docblock"><p>Returns a parallel iterator over substrings terminated by a
given character or predicate, similar to <code>str::split_terminator</code>.
Its equivalent to <code>par_split</code>, except it doesnt 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>, <code>&amp;[char]</code>, <code>[char; N]</code>, <code>&amp;[char; N]</code>,
and any function or closure <code>F: Fn(char) -&gt; bool + Sync + Send</code>.</p>
<h5 id="examples-6"><a class="doc-anchor" href="#examples-6">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rayon::prelude::<span class="kw-2">*</span>;
<span class="kw">let </span>parts: Vec&lt;<span class="kw">_</span>&gt; = <span class="string">"((1 + 3) * 2)"
</span>.par_split_terminator(|c| c == <span class="string">'(' </span>|| c == <span class="string">')'</span>)
.collect();
<span class="macro">assert_eq!</span>(<span class="macro">vec!</span>[<span class="string">""</span>, <span class="string">""</span>, <span class="string">"1 + 3"</span>, <span class="string">" * 2"</span>], parts);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.par_lines" class="method"><a class="src rightside" href="../../src/rayon/str.rs.html#216-218">Source</a><h4 class="code-header">fn <a href="#method.par_lines" class="fn">par_lines</a>(&amp;self) -&gt; <a class="struct" href="struct.Lines.html" title="struct rayon::str::Lines">Lines</a>&lt;'_&gt;</h4></section></summary><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>
<h5 id="examples-7"><a class="doc-anchor" href="#examples-7">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rayon::prelude::<span class="kw-2">*</span>;
<span class="kw">let </span>lengths: Vec&lt;<span class="kw">_</span>&gt; = <span class="string">"hello world\nfizbuzz"
</span>.par_lines()
.map(|l| l.len())
.collect();
<span class="macro">assert_eq!</span>(<span class="macro">vec!</span>[<span class="number">11</span>, <span class="number">7</span>], lengths);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.par_split_whitespace" class="method"><a class="src rightside" href="../../src/rayon/str.rs.html#255-257">Source</a><h4 class="code-header">fn <a href="#method.par_split_whitespace" class="fn">par_split_whitespace</a>(&amp;self) -&gt; <a class="struct" href="struct.SplitWhitespace.html" title="struct rayon::str::SplitWhitespace">SplitWhitespace</a>&lt;'_&gt;</h4></section></summary><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>.
If you only want to split on ASCII whitespace instead, use
<a href="trait.ParallelString.html#method.par_split_ascii_whitespace" title="method rayon::str::ParallelString::par_split_ascii_whitespace"><code>par_split_ascii_whitespace</code></a>.</p>
<h5 id="examples-8"><a class="doc-anchor" href="#examples-8">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rayon::prelude::<span class="kw-2">*</span>;
<span class="kw">let </span>longest = <span class="string">"which is the longest word?"
</span>.par_split_whitespace()
.max_by_key(|word| word.len());
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="string">"longest"</span>), longest);</code></pre></div>
<p>All kinds of whitespace are considered:</p>
<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>words: Vec&lt;<span class="kw-2">&amp;</span>str&gt; = <span class="string">" Mary had\ta\u{2009}little \n\t lamb"
</span>.par_split_whitespace()
.collect();
<span class="macro">assert_eq!</span>(words, [<span class="string">"Mary"</span>, <span class="string">"had"</span>, <span class="string">"a"</span>, <span class="string">"little"</span>, <span class="string">"lamb"</span>]);</code></pre></div>
<p>If the string is empty or all whitespace, the iterator yields no string slices:</p>
<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="macro">assert_eq!</span>(<span class="string">""</span>.par_split_whitespace().count(), <span class="number">0</span>);
<span class="macro">assert_eq!</span>(<span class="string">" "</span>.par_split_whitespace().count(), <span class="number">0</span>);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.par_split_ascii_whitespace" class="method"><a class="src rightside" href="../../src/rayon/str.rs.html#292-294">Source</a><h4 class="code-header">fn <a href="#method.par_split_ascii_whitespace" class="fn">par_split_ascii_whitespace</a>(&amp;self) -&gt; <a class="struct" href="struct.SplitAsciiWhitespace.html" title="struct rayon::str::SplitAsciiWhitespace">SplitAsciiWhitespace</a>&lt;'_&gt;</h4></section></summary><div class="docblock"><p>Returns a parallel iterator over the sub-slices of a string that are
separated by any amount of ASCII whitespace.</p>
<p>To split by Unicode <code>White_Space</code> instead, use
<a href="trait.ParallelString.html#method.par_split_whitespace" title="method rayon::str::ParallelString::par_split_whitespace"><code>par_split_whitespace</code></a>.</p>
<h5 id="examples-9"><a class="doc-anchor" href="#examples-9">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rayon::prelude::<span class="kw-2">*</span>;
<span class="kw">let </span>longest = <span class="string">"which is the longest word?"
</span>.par_split_ascii_whitespace()
.max_by_key(|word| word.len());
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(<span class="string">"longest"</span>), longest);</code></pre></div>
<p>All kinds of ASCII whitespace are considered, but not Unicode <code>White_Space</code>:</p>
<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>words: Vec&lt;<span class="kw-2">&amp;</span>str&gt; = <span class="string">" Mary had\ta\u{2009}little \n\t lamb"
</span>.par_split_ascii_whitespace()
.collect();
<span class="macro">assert_eq!</span>(words, [<span class="string">"Mary"</span>, <span class="string">"had"</span>, <span class="string">"a\u{2009}little"</span>, <span class="string">"lamb"</span>]);</code></pre></div>
<p>If the string is empty or all ASCII whitespace, the iterator yields no string slices:</p>
<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="macro">assert_eq!</span>(<span class="string">""</span>.par_split_whitespace().count(), <span class="number">0</span>);
<span class="macro">assert_eq!</span>(<span class="string">" "</span>.par_split_whitespace().count(), <span class="number">0</span>);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.par_matches" class="method"><a class="src rightside" href="../../src/rayon/str.rs.html#313-318">Source</a><h4 class="code-header">fn <a href="#method.par_matches" class="fn">par_matches</a>&lt;P: Pattern&gt;(&amp;self, pattern: P) -&gt; <a class="struct" href="struct.Matches.html" title="struct rayon::str::Matches">Matches</a>&lt;'_, P&gt;</h4></section></summary><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>, <code>&amp;[char]</code>, <code>[char; N]</code>, <code>&amp;[char; N]</code>,
and any function or closure <code>F: Fn(char) -&gt; bool + Sync + Send</code>.</p>
<h5 id="examples-10"><a class="doc-anchor" href="#examples-10">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rayon::prelude::<span class="kw-2">*</span>;
<span class="kw">let </span>total = <span class="string">"1, 2, buckle, 3, 4, door"
</span>.par_matches(char::is_numeric)
.map(|s| s.parse::&lt;i32&gt;().expect(<span class="string">"digit"</span>))
.sum();
<span class="macro">assert_eq!</span>(<span class="number">10</span>, total);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.par_match_indices" class="method"><a class="src rightside" href="../../src/rayon/str.rs.html#336-341">Source</a><h4 class="code-header">fn <a href="#method.par_match_indices" class="fn">par_match_indices</a>&lt;P: Pattern&gt;(&amp;self, pattern: P) -&gt; <a class="struct" href="struct.MatchIndices.html" title="struct rayon::str::MatchIndices">MatchIndices</a>&lt;'_, P&gt;</h4></section></summary><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>, <code>&amp;[char]</code>, <code>[char; N]</code>, <code>&amp;[char; N]</code>,
and any function or closure <code>F: Fn(char) -&gt; bool + Sync + Send</code>.</p>
<h5 id="examples-11"><a class="doc-anchor" href="#examples-11">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>rayon::prelude::<span class="kw-2">*</span>;
<span class="kw">let </span>digits: Vec&lt;<span class="kw">_</span>&gt; = <span class="string">"1, 2, buckle, 3, 4, door"
</span>.par_match_indices(char::is_numeric)
.collect();
<span class="macro">assert_eq!</span>(digits, <span class="macro">vec!</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>)]);</code></pre></div></div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-ParallelString-for-str" class="impl"><a class="src rightside" href="../../src/rayon/str.rs.html#344-349">Source</a><a href="#impl-ParallelString-for-str" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.ParallelString.html" title="trait rayon::str::ParallelString">ParallelString</a> for <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.str.html">str</a></h3></section></summary><div class="impl-items"><section id="method.as_parallel_string" class="method trait-impl"><a class="src rightside" href="../../src/rayon/str.rs.html#346-348">Source</a><a href="#method.as_parallel_string" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.as_parallel_string" class="fn">as_parallel_string</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.str.html">str</a></h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../../trait.impl/rayon/str/trait.ParallelString.js" data-ignore-extern-crates="std" async></script></section></div></main></body></html>