/rust/registry/src/index.crates.io-1949cf8c6b5b557f/fuzzy-matcher-0.3.7/src/lib.rs
Line | Count | Source |
1 | | pub mod clangd; |
2 | | pub mod skim; |
3 | | mod util; |
4 | | |
5 | | #[cfg(not(feature = "compact"))] |
6 | | type IndexType = usize; |
7 | | #[cfg(not(feature = "compact"))] |
8 | | type ScoreType = i64; |
9 | | |
10 | | #[cfg(feature = "compact")] |
11 | | type IndexType = u32; |
12 | | #[cfg(feature = "compact")] |
13 | | type ScoreType = i32; |
14 | | |
15 | | pub 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 | 0 | fn fuzzy_match(&self, choice: &str, pattern: &str) -> Option<ScoreType> { |
21 | 0 | self.fuzzy_indices(choice, pattern).map(|(score, _)| score) |
22 | 0 | } |
23 | | } |