fn fuzzy_score(
    choice_ch: char,
    choice_idx: usize,
    choice_prev_ch: char,
    pat_ch: char,
    pat_idx: usize,
    _pat_prev_ch: char,
) -> i64 {
    let mut score = BONUS_MATCHED;

    let choice_prev_ch_type = CharType::of(choice_prev_ch);
    let choice_role = CharRole::of(choice_prev_ch, choice_ch);

    if pat_ch == choice_ch {
        if pat_ch.is_uppercase() {
            score += BONUS_UPPER_MATCH;
        } else {
            score += BONUS_CASE_MATCH;
        }
    } else {
        score += PENALTY_CASE_UNMATCHED;
    }

    // apply bonus for camelCases
    if choice_role == CharRole::Head
        || choice_role == CharRole::Break
        || choice_role == CharRole::Camel
    {
        score += BONUS_CAMEL;
    }

    // apply bonus for matches after a separator
    if choice_prev_ch_type == CharType::HardSep || choice_prev_ch_type == CharType::SoftSep {
        score += BONUS_SEPARATOR;
    }

    if pat_idx == 0 {
        score += max((choice_idx as i64) * PENALTY_LEADING, PENALTY_MAX_LEADING);
    }

    score
}
// judge how many scores the current index should get
judge how many scores the current index should get
judge how many scores the current index should get
fn fuzzy_score(
    choice_ch: char,
    choice_idx: usize,
    choice_prev_ch: char,
    pat_ch: char,
    pat_idx: usize,
    _pat_prev_ch: char,
) -> i64 {
    let mut score = BONUS_MATCHED;
    let choice_prev_ch_type = CharType::of(choice_prev_ch);
    let choice_role = CharRole::of(choice_prev_ch, choice_ch);
    if pat_ch == choice_ch {
        if pat_ch.is_uppercase() {
            score += BONUS_UPPER_MATCH;
        } else {
            score += BONUS_CASE_MATCH;
        }
    } else {
        score += PENALTY_CASE_UNMATCHED;
    }
    // apply bonus for camelCases
    if choice_role == CharRole::Head
        || choice_role == CharRole::Break
        || choice_role == CharRole::Camel
    {
        score += BONUS_CAMEL;
    }
    // apply bonus for matches after a separator
    if choice_prev_ch_type == CharType::HardSep || choice_prev_ch_type == CharType::SoftSep {
        score += BONUS_SEPARATOR;
    }
    if pat_idx == 0 {
        score += max((choice_idx as i64) * PENALTY_LEADING, PENALTY_MAX_LEADING);
    }
    score
}
fn fuzzy_score ( choice_ch : char , choice_idx : usize , choice_prev_ch : char , pat_ch : char , pat_idx : usize , _pat_prev_ch : char , ) -> i64 { let mut score = BONUS_MATCHED ; let choice_prev_ch_type = CharType :: of ( choice_prev_ch ) ; let choice_role = CharRole :: of ( choice_prev_ch , choice_ch ) ; if pat_ch == choice_ch { if pat_ch . is_uppercase ( ) { score += BONUS_UPPER_MATCH ; } else { score += BONUS_CASE_MATCH ; } } else { score += PENALTY_CASE_UNMATCHED ; } // apply bonus for camelCases if choice_role == CharRole :: Head || choice_role == CharRole :: Break || choice_role == CharRole :: Camel { score += BONUS_CAMEL ; } // apply bonus for matches after a separator if choice_prev_ch_type == CharType :: HardSep || choice_prev_ch_type == CharType :: SoftSep { score += BONUS_SEPARATOR ; } if pat_idx == 0 { score += max ( ( choice_idx as i64 ) * PENALTY_LEADING , PENALTY_MAX_LEADING ) ; } score }
judge how many scores the current index should get
judge how many scores the current index should get
choice_ch
char
choice_idx
usize
choice_prev_ch
char
pat_ch
char
pat_idx
usize
_pat_prev_ch
char