[][src]Struct sublime_fuzzy::FuzzySearch

pub struct FuzzySearch<'a> { /* fields omitted */ }

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

impl<'a> FuzzySearch<'a>[src]

pub fn new(query: &'a str, target: &'a str) -> Self[src]

Creates a new search to match query in target.

Note that whitespace in query will be ignored.

pub fn score_with(self, scoring: &'a Scoring) -> Self[src]

Use custom scoring values.

If not specified will use Scoring::default().

pub fn case_sensitive(self) -> Self[src]

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).

pub fn case_insensitive(self) -> Self[src]

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.

pub fn best_match(self) -> Option<Match>[src]

Finds the best match of the query in the target string.

Always tries to match the full pattern. A partial match is considered invalid and will return None. Will also return None in case the query or target string are empty.

Auto Trait Implementations

impl<'a> RefUnwindSafe for FuzzySearch<'a>[src]

impl<'a> Send for FuzzySearch<'a>[src]

impl<'a> Sync for FuzzySearch<'a>[src]

impl<'a> Unpin for FuzzySearch<'a>[src]

impl<'a> UnwindSafe for FuzzySearch<'a>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.