fuzzy_matcher/
lib.rs

1pub mod clangd;
2pub mod simple;
3pub mod skim;
4mod util;
5
6type IndexType = usize;
7type ScoreType = i64;
8
9pub trait FuzzyMatcher: Send + Sync {
10    /// fuzzy match choice with pattern, and return the score & matched indices of characters
11    fn fuzzy_indices(&self, choice: &str, pattern: &str) -> Option<(ScoreType, Vec<IndexType>)>;
12
13    /// fuzzy match choice with pattern, and return the score of matching
14    fn fuzzy_match(&self, choice: &str, pattern: &str) -> Option<ScoreType> {
15        self.fuzzy_indices(choice, pattern).map(|(score, _)| score)
16    }
17}