Trait rayon::str::ParallelString [−][src]
pub trait ParallelString { fn as_parallel_string(&self) -> &str; fn par_chars(&self) -> Chars<'_> { ... } fn par_char_indices(&self) -> CharIndices<'_> { ... } fn par_bytes(&self) -> Bytes<'_> { ... } fn par_encode_utf16(&self) -> EncodeUtf16<'_> { ... } fn par_split<P: Pattern>(&self, separator: P) -> Split<'_, P> { ... } fn par_split_terminator<P: Pattern>(
&self,
terminator: P
) -> SplitTerminator<'_, P> { ... } fn par_lines(&self) -> Lines<'_> { ... } fn par_split_whitespace(&self) -> SplitWhitespace<'_> { ... } fn par_matches<P: Pattern>(&self, pattern: P) -> Matches<'_, P> { ... } fn par_match_indices<P: Pattern>(&self, pattern: P) -> MatchIndices<'_, P> { ... } }
Expand description
Parallel extensions for strings.
Required methods
fn as_parallel_string(&self) -> &str
[src]
fn as_parallel_string(&self) -> &str
[src]Returns a plain string slice, which is used to implement the rest of the parallel methods.
Provided methods
Returns a parallel iterator over the characters of a string.
Examples
use rayon::prelude::*; let max = "hello".par_chars().max_by_key(|c| *c as i32); assert_eq!(Some('o'), max);
fn par_char_indices(&self) -> CharIndices<'_>
[src]
fn par_char_indices(&self) -> CharIndices<'_>
[src]Returns a parallel iterator over the characters of a string, with their positions.
Examples
use rayon::prelude::*; let min = "hello".par_char_indices().min_by_key(|&(_i, c)| c as i32); assert_eq!(Some((1, 'e')), min);
Returns a parallel iterator over the bytes of a string.
Note that multi-byte sequences (for code points greater than U+007F
)
are produced as separate items, but will not be split across threads.
If you would prefer an indexed iterator without that guarantee, consider
string.as_bytes().par_iter().cloned()
instead.
Examples
use rayon::prelude::*; let max = "hello".par_bytes().max(); assert_eq!(Some(b'o'), max);
fn par_encode_utf16(&self) -> EncodeUtf16<'_>
[src]
fn par_encode_utf16(&self) -> EncodeUtf16<'_>
[src]Returns a parallel iterator over a string encoded as UTF-16.
Note that surrogate pairs (for code points greater than U+FFFF
) are
produced as separate items, but will not be split across threads.
Examples
use rayon::prelude::*; let max = "hello".par_encode_utf16().max(); assert_eq!(Some(b'o' as u16), max); let text = "Zażółć gęślą jaźń"; let utf8_len = text.len(); let utf16_len = text.par_encode_utf16().count(); assert!(utf16_len <= utf8_len);
Returns a parallel iterator over substrings separated by a
given character or predicate, similar to str::split
.
Note: the Pattern
trait is private, for use only by Rayon itself.
It is implemented for char
and any F: Fn(char) -> bool + Sync + Send
.
Examples
use rayon::prelude::*; let total = "1, 2, buckle, 3, 4, door" .par_split(',') .filter_map(|s| s.trim().parse::<i32>().ok()) .sum(); assert_eq!(10, total);
fn par_split_terminator<P: Pattern>(
&self,
terminator: P
) -> SplitTerminator<'_, P>
[src]
fn par_split_terminator<P: Pattern>(
&self,
terminator: P
) -> SplitTerminator<'_, P>
[src]Returns a parallel iterator over substrings terminated by a
given character or predicate, similar to str::split_terminator
.
It’s equivalent to par_split
, except it doesn’t produce an empty
substring after a trailing terminator.
Note: the Pattern
trait is private, for use only by Rayon itself.
It is implemented for char
and any F: Fn(char) -> bool + Sync + Send
.
Examples
use rayon::prelude::*; let parts: Vec<_> = "((1 + 3) * 2)" .par_split_terminator(|c| c == '(' || c == ')') .collect(); assert_eq!(vec!["", "", "1 + 3", " * 2"], parts);
Returns a parallel iterator over the lines of a string, ending with an
optional carriage return and with a newline (\r\n
or just \n
).
The final line ending is optional, and line endings are not included in
the output strings.
Examples
use rayon::prelude::*; let lengths: Vec<_> = "hello world\nfizbuzz" .par_lines() .map(|l| l.len()) .collect(); assert_eq!(vec![11, 7], lengths);
fn par_split_whitespace(&self) -> SplitWhitespace<'_>
[src]
fn par_split_whitespace(&self) -> SplitWhitespace<'_>
[src]Returns a parallel iterator over the sub-slices of a string that are separated by any amount of whitespace.
As with str::split_whitespace
, ‘whitespace’ is defined according to
the terms of the Unicode Derived Core Property White_Space
.
Examples
use rayon::prelude::*; let longest = "which is the longest word?" .par_split_whitespace() .max_by_key(|word| word.len()); assert_eq!(Some("longest"), longest);
fn par_matches<P: Pattern>(&self, pattern: P) -> Matches<'_, P>
[src]
fn par_matches<P: Pattern>(&self, pattern: P) -> Matches<'_, P>
[src]Returns a parallel iterator over substrings that match a
given character or predicate, similar to str::matches
.
Note: the Pattern
trait is private, for use only by Rayon itself.
It is implemented for char
and any F: Fn(char) -> bool + Sync + Send
.
Examples
use rayon::prelude::*; let total = "1, 2, buckle, 3, 4, door" .par_matches(char::is_numeric) .map(|s| s.parse::<i32>().expect("digit")) .sum(); assert_eq!(10, total);
fn par_match_indices<P: Pattern>(&self, pattern: P) -> MatchIndices<'_, P>
[src]
fn par_match_indices<P: Pattern>(&self, pattern: P) -> MatchIndices<'_, P>
[src]Returns a parallel iterator over substrings that match a given character
or predicate, with their positions, similar to str::match_indices
.
Note: the Pattern
trait is private, for use only by Rayon itself.
It is implemented for char
and any F: Fn(char) -> bool + Sync + Send
.
Examples
use rayon::prelude::*; let digits: Vec<_> = "1, 2, buckle, 3, 4, door" .par_match_indices(char::is_numeric) .collect(); assert_eq!(digits, vec![(0, "1"), (3, "2"), (14, "3"), (17, "4")]);