(text: &str, needle: &str)
| 254 | } |
| 255 | |
| 256 | fn contains_bounded(text: &str, needle: &str) -> bool { |
| 257 | text.match_indices(needle).any(|(idx, _)| { |
| 258 | let before = text[..idx].chars().next_back(); |
| 259 | let after = text[idx + needle.len()..].chars().next(); |
| 260 | is_reference_boundary(before) && is_reference_boundary(after) |
| 261 | }) |
| 262 | } |
| 263 | |
| 264 | fn is_reference_boundary(ch: Option<char>) -> bool { |
| 265 | ch.map(|ch| !ch.is_ascii_alphanumeric() && ch != '_' && ch != '-') |
no test coverage detected