Function score

Source
pub fn score(query: &str, candi: &str) -> usize
Expand description

Scores how well query matches the candi string.

The score is based on whether query is a subsequence of candi, with additional weighting:

  • Characters matched earlier in candi get higher weight.
  • Consecutive matched characters earn a small bonus.
  • Exact matches yield the highest score (100).

§Arguments

  • query - The search query string slice.
  • candi - The candidate string slice to be matched against.

§Returns

A usize score between 0 and 100, higher means better match.

§Examples

let score = matchr::score("fefe", "fefe");
assert_eq!(score, 100);