pub fn score_consecutives(
    query: &Query,
    subject: &Text,
    query_position: usize,
    subject_position: usize,
    is_start: bool,
) -> f32 {
    let query_left = query.len() - query_position;
    let subject_left = subject.len() - subject_position;

    let left = if subject_left < query_left {
        subject_left
    } else {
        query_left
    };

    let mut same_case = 0;
    let mut sz = 1;

    if query.grapheme_at(query_position) == subject.grapheme_at(subject_position) {
        same_case += 1;
    }

    let query_iter = query.lowercase_iter().enumerate().skip(query_position + 1);
    let mut subject_iter = subject
        .lowercase_iter()
        .enumerate()
        .skip(subject_position + 1);

    let mut subject_cursor = subject_position;

    for (qindex, query_grapheme) in query_iter {
        if let Some((index, subject_grapheme)) = subject_iter.next() {
            if query_grapheme == subject_grapheme {
                subject_cursor = index;

                if query.grapheme_at(qindex) == subject.grapheme_at(index) {
                    same_case += 1;
                }
            } else {
                break;
            }
        } else {
            break;
        }

        if sz >= left {
            break;
        }

        sz += 1;
    }

    if sz == 1 {
        let score = 1 + 2 * same_case;

        return score as f32;
    }

    let is_end = is_end_of_word(subject, subject_cursor);

    score_pattern(sz, query.len(), same_case, is_start, is_end)
}
/// Forward search for a sequence of consecutive characters and return the score
Forward search for a sequence of consecutive characters and return the score
Forward search for a sequence of consecutive characters and return the score
pub fn score_consecutives(
    query: &Query,
    subject: &Text,
    query_position: usize,
    subject_position: usize,
    is_start: bool,
) -> f32 {
    let query_left = query.len() - query_position;
    let subject_left = subject.len() - subject_position;
    let left = if subject_left < query_left {
        subject_left
    } else {
        query_left
    };
    let mut same_case = 0;
    let mut sz = 1;
    if query.grapheme_at(query_position) == subject.grapheme_at(subject_position) {
        same_case += 1;
    }
    let query_iter = query.lowercase_iter().enumerate().skip(query_position + 1);
    let mut subject_iter = subject
        .lowercase_iter()
        .enumerate()
        .skip(subject_position + 1);
    let mut subject_cursor = subject_position;
    for (qindex, query_grapheme) in query_iter {
        if let Some((index, subject_grapheme)) = subject_iter.next() {
            if query_grapheme == subject_grapheme {
                subject_cursor = index;
                if query.grapheme_at(qindex) == subject.grapheme_at(index) {
                    same_case += 1;
                }
            } else {
                break;
            }
        } else {
            break;
        }
        if sz >= left {
            break;
        }
        sz += 1;
    }
    if sz == 1 {
        let score = 1 + 2 * same_case;
        return score as f32;
    }
    let is_end = is_end_of_word(subject, subject_cursor);
    score_pattern(sz, query.len(), same_case, is_start, is_end)
}
pub fn score_consecutives ( query : & Query , subject : & Text , query_position : usize , subject_position : usize , is_start : bool , ) -> f32 { let query_left = query . len ( ) - query_position ; let subject_left = subject . len ( ) - subject_position ; let left = if subject_left < query_left { subject_left } else { query_left } ; let mut same_case = 0 ; let mut sz = 1 ; if query . grapheme_at ( query_position ) == subject . grapheme_at ( subject_position ) { same_case += 1 ; } let query_iter = query . lowercase_iter ( ) . enumerate ( ) . skip ( query_position + 1 ) ; let mut subject_iter = subject . lowercase_iter ( ) . enumerate ( ) . skip ( subject_position + 1 ) ; let mut subject_cursor = subject_position ; for ( qindex , query_grapheme ) in query_iter { if let Some ( ( index , subject_grapheme ) ) = subject_iter . next ( ) { if query_grapheme == subject_grapheme { subject_cursor = index ; if query . grapheme_at ( qindex ) == subject . grapheme_at ( index ) { same_case += 1 ; } } else { break ; } } else { break ; } if sz >= left { break ; } sz += 1 ; } if sz == 1 { let score = 1 + 2 * same_case ; return score as f32 ; } let is_end = is_end_of_word ( subject , subject_cursor ) ; score_pattern ( sz , query . len ( ) , same_case , is_start , is_end ) }
Forward search for a sequence of consecutive characters and return the score
Forward search for a sequence of consecutive characters and return the score
query
&Query
subject
&Text
query_position
usize
subject_position
usize
is_start
bool