pub struct FuzzyMatcher { /* private fields */ }Expand description
Fuzzy matcher instance. Holds memory for the state of the fuzzy matcher so that large batches of queries can be processed with minimal allocations. When performing a large batch of fuzzy match queries, use a common instance of this struct to improve performance by avoiding extra allocations.
Implementations§
Source§impl FuzzyMatcher
impl FuzzyMatcher
Sourcepub fn fuzzy_match(&mut self, target: &str, query: &str) -> Option<usize>
pub fn fuzzy_match(&mut self, target: &str, query: &str) -> Option<usize>
Fuzzy match a string against a query string. Returns a score that is higher for
a more confident match, or None if the query does not match the target string.
§Examples
let mut matcher = code_fuzzy_match::FuzzyMatcher::new();
let matches = matcher.fuzzy_match("the quick brown fox", "bro fox");
assert!(matches.is_some());
let no_match = matcher.fuzzy_match("the quick brown fox", "cat");
assert!(no_match.is_none());
let high_score = matcher.fuzzy_match("Example string", "example");
let lower_score = matcher.fuzzy_match("Example string", "str");
assert!(high_score.unwrap() > lower_score.unwrap());Auto Trait Implementations§
impl Freeze for FuzzyMatcher
impl RefUnwindSafe for FuzzyMatcher
impl Send for FuzzyMatcher
impl Sync for FuzzyMatcher
impl Unpin for FuzzyMatcher
impl UnsafeUnpin for FuzzyMatcher
impl UnwindSafe for FuzzyMatcher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more