verso/reader/search.rs
1#[derive(Debug, Clone, Copy)]
2pub enum SearchDirection {
3 Forward,
4 Backward,
5}
6
7pub fn find_matches(text: &str, needle: &str, _dir: SearchDirection) -> Vec<usize> {
8 if needle.is_empty() {
9 return vec![];
10 }
11 let hay = text.to_lowercase();
12 let nee = needle.to_lowercase();
13 hay.match_indices(&nee)
14 .map(|(i, _)| text[..i].chars().count())
15 .collect()
16}