fn calculate_match_score(
        &self,
        prev_ch: char,
        c: char,
        p: char,
        c_idx: usize,
        _p_idx: usize,
        case_sensitive: bool,
    ) -> Option<u16> {
        if !char_equal(c, p, case_sensitive) {
            return None;
        }

        let score = self.score_config.score_match;

        // check bonus for start of camel case, etc.
        let prev_ch_type = CharType::of(prev_ch);
        let ch_type = CharType::of(c);
        let mut bonus = self.in_place_bonus(prev_ch_type, ch_type);

        // bonus for matching the start of the whole choice string
        if c_idx == 0 {
            bonus *= self.score_config.bonus_first_char_multiplier;
        }

        // penalty on case mismatch
        if !case_sensitive && p != c {
            bonus += self.score_config.penalty_case_mismatch;
        }

        Some(max(0, score + bonus) as u16)
    }
/// Calculate the matching score of the characters
/// return None if not matched.
Calculate the matching score of the characters
return None if not matched.
Calculate the matching score of the characters return None if not matched .
fn calculate_match_score(
        &self,
        prev_ch: char,
        c: char,
        p: char,
        c_idx: usize,
        _p_idx: usize,
        case_sensitive: bool,
    ) -> Option<u16> {
        if !char_equal(c, p, case_sensitive) {
            return None;
        }
        let score = self.score_config.score_match;
        // check bonus for start of camel case, etc.
        let prev_ch_type = CharType::of(prev_ch);
        let ch_type = CharType::of(c);
        let mut bonus = self.in_place_bonus(prev_ch_type, ch_type);
        // bonus for matching the start of the whole choice string
        if c_idx == 0 {
            bonus *= self.score_config.bonus_first_char_multiplier;
        }
        // penalty on case mismatch
        if !case_sensitive && p != c {
            bonus += self.score_config.penalty_case_mismatch;
        }
        Some(max(0, score + bonus) as u16)
    }
fn calculate_match_score ( & self , prev_ch : char , c : char , p : char , c_idx : usize , _p_idx : usize , case_sensitive : bool , ) -> Option < u16 > { if ! char_equal ( c , p , case_sensitive ) { return None ; } let score = self . score_config . score_match ; // check bonus for start of camel case, etc. let prev_ch_type = CharType :: of ( prev_ch ) ; let ch_type = CharType :: of ( c ) ; let mut bonus = self . in_place_bonus ( prev_ch_type , ch_type ) ; // bonus for matching the start of the whole choice string if c_idx == 0 { bonus *= self . score_config . bonus_first_char_multiplier ; } // penalty on case mismatch if ! case_sensitive && p != c { bonus += self . score_config . penalty_case_mismatch ; } Some ( max ( 0 , score + bonus ) as u16 ) }
Calculate the matching score of the characters
return None if not matched.
Calculate the matching score of the characters return None if not matched .
&self
prev_ch
char
c
char
p
char
c_idx
usize
_p_idx
usize
case_sensitive
bool