pub struct FuzzySearch<'a> { /* private fields */ }
Expand description
Describes a fuzzy search. Alternative to best_match
which allows for more configuration.
§Examples
Basic usage:
use sublime_fuzzy::{FuzzySearch, Scoring};
let scoring = Scoring::emphasize_word_starts();
let result = FuzzySearch::new("something", "Some Search Thing")
.score_with(&scoring)
.case_insensitive()
.best_match();
assert!(result.is_some());
Implementations§
Source§impl<'a> FuzzySearch<'a>
impl<'a> FuzzySearch<'a>
Sourcepub fn new(query: &'a str, target: &'a str) -> Self
pub fn new(query: &'a str, target: &'a str) -> Self
Creates a new search to match query
in target
.
Note that whitespace in query will be ignored.
Sourcepub fn score_with(self, scoring: &'a Scoring) -> Self
pub fn score_with(self, scoring: &'a Scoring) -> Self
Use custom scoring values.
If not specified will use Scoring::default()
.
Sourcepub fn case_sensitive(self) -> Self
pub fn case_sensitive(self) -> Self
Only match query chars in the target string if case matches.
Scoring::bonus_match_case
will not be applied if this is set (because a char match will
always also be a case match).
Sourcepub fn case_insensitive(self) -> Self
pub fn case_insensitive(self) -> Self
Ignore case when matching query chars in the target string.
If not only the char but also the case matches, Scoring::bonus_match_case
will be added to
the score. If that behavior is not wanted the bonus can be set to 0 with custom scoring.
Auto Trait Implementations§
impl<'a> Freeze for FuzzySearch<'a>
impl<'a> RefUnwindSafe for FuzzySearch<'a>
impl<'a> Send for FuzzySearch<'a>
impl<'a> Sync for FuzzySearch<'a>
impl<'a> Unpin for FuzzySearch<'a>
impl<'a> UnwindSafe for FuzzySearch<'a>
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