Skip to main content

CandidateMatcher

Trait CandidateMatcher 

Source
pub trait CandidateMatcher: Send + Sync {
    // Required method
    fn matches(
        &self,
        query: &str,
        candidate: &RawCandidate,
    ) -> Option<(MatchScore, Vec<Range<usize>>)>;
}
Expand description

Matches and scores candidates against a query string. The default v1 matcher (match:prefix) returns Some only when the query is a prefix of candidate.text. The fuzzy matcher (orderless-equivalent) returns sub-character match ranges and a score that decays with skipped chars.

Required Methods§

Source

fn matches( &self, query: &str, candidate: &RawCandidate, ) -> Option<(MatchScore, Vec<Range<usize>>)>

Score the candidate against query. None means “no match” (filter out). The byte ranges record which parts of candidate.text the matcher consumed – the renderer paints these with the match-face style.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§