Я использую rayon для выполнения параллельной итерации над текстом и пытаюсь вывести строки, содержащие определенный символ. Я использую matches()
: игровая площадка
use rayon::prelude::*;
fn main() {
let text =
"Some are born great, some achieve greatness, and some have greatness thrust upon them."
.to_string();
check(text, 's');
}
fn check(text: String, ch: char) {
let words: Vec<_> = text.split_whitespace().collect();
let words_with_ch: Vec<_> = words.par_iter().map(|ch| words.matches(ch)).collect();
println!(
"The following words contain the letter {:?}: {:?}",
ch, words_with_ch
);
}
, но отображается ошибка:
error[E0599]: no method named `matches` found for type `std::vec::Vec<&str>` in the current scope
--> src/main.rs:12:65
|
12 | let words_with_ch: Vec<_> = words.par_iter().map(|ch| words.matches(ch)).collect();
| ^^^^^^^
Как я могу решить эту проблемуошибка компиляции?