fuzzy_matcher/
lib.rs

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