Я пытаюсь перебрать предложение и получить слова с помощью регулярного выражения:
use regex::Regex; // 1.0.6
fn example() {
let re = Regex::new(r"\w+").unwrap();
let sample_text = "This is me me.";
for caps in re.captures_iter(&sample_text) {
if let Some(cap) = caps.get(0) {
let word = cap.to_string();
}
}
}
Я получаю приведенную ниже ошибку.
error[E0599]: no method named `to_string` found for type `regex::re_unicode::Match<'_>` in the current scope
--> src/lib.rs:8:28
|
8 | let word = cap.to_string();
| ^^^^^^^^^
|
= note: the method `to_string` exists but the following trait bounds were not satisfied:
`regex::re_unicode::Match<'_> : std::string::ToString`
Чего мне не хватает?