pub(crate) fn extract_identifier_tokens(text: &str) -> Vec<String> {
let mut tokens = Vec::new();
let mut current = String::new();
for ch in text.chars() {
if ch.is_alphanumeric() || ch == '_' {
current.push(ch);
} else {
if is_interesting_token(¤t) {
tokens.push(current.clone());
}
current.clear();
}
}
if is_interesting_token(¤t) {
tokens.push(current);
}
tokens.sort();
tokens.dedup();
tokens
}
fn is_interesting_token(token: &str) -> bool {
token.len() > 2
&& !matches!(
token,
"assert"
| "assert_eq"
| "assert_ne"
| "assert_matches"
| "let"
| "mut"
| "true"
| "false"
| "Some"
| "None"
| "Ok"
| "Err"
| "unwrap"
| "expect"
| "is_ok"
| "is_err"
)
}