pub fn score_exact_match(query: &Query, subject: &Text) -> Option<ExactMatchResult> {
    let (mut position, mut same_case) = sequence_position(query, subject, 0)?;

    let mut is_start;
    is_start = is_start_of_word(subject, position);

    if !is_start {
        // try a second sequence to see if is better (word start) than the previous one
        // we don't want to try more than twice
        if let Some((sec_position, sec_same_case)) =
            sequence_position(query, subject, position + query.len())
        {
            is_start = is_start_of_word(subject, sec_position);

            if is_start {
                position = sec_position;
                same_case = sec_same_case;
            }
        }
    }

    let is_end = is_end_of_word(subject, (position + query.len()) - 1);
    let score = score_quality(
        query.len(),
        subject.len(),
        score_pattern(query.len(), query.len(), same_case, is_start, is_end),
        position as f32,
    );
    let matches: Vec<usize> = (position..(position + query.len())).collect();

    Some(ExactMatchResult::new(score, matches))
}
/// Calculate the score of an exact match, if any
Calculate the score of an exact match, if any
Calculate the score of an exact match if any
pub fn score_exact_match(query: &Query, subject: &Text) -> Option<ExactMatchResult> {
    let (mut position, mut same_case) = sequence_position(query, subject, 0)?;
    let mut is_start;
    is_start = is_start_of_word(subject, position);
    if !is_start {
        // try a second sequence to see if is better (word start) than the previous one
        // we don't want to try more than twice
        if let Some((sec_position, sec_same_case)) =
            sequence_position(query, subject, position + query.len())
        {
            is_start = is_start_of_word(subject, sec_position);
            if is_start {
                position = sec_position;
                same_case = sec_same_case;
            }
        }
    }
    let is_end = is_end_of_word(subject, (position + query.len()) - 1);
    let score = score_quality(
        query.len(),
        subject.len(),
        score_pattern(query.len(), query.len(), same_case, is_start, is_end),
        position as f32,
    );
    let matches: Vec<usize> = (position..(position + query.len())).collect();
    Some(ExactMatchResult::new(score, matches))
}
pub fn score_exact_match ( query : & Query , subject : & Text ) -> Option < ExactMatchResult > { let ( mut position , mut same_case ) = sequence_position ( query , subject , 0 ) ? ; let mut is_start ; is_start = is_start_of_word ( subject , position ) ; if ! is_start { // try a second sequence to see if is better (word start) than the previous one // we don't want to try more than twice if let Some ( ( sec_position , sec_same_case ) ) = sequence_position ( query , subject , position + query . len ( ) ) { is_start = is_start_of_word ( subject , sec_position ) ; if is_start { position = sec_position ; same_case = sec_same_case ; } } } let is_end = is_end_of_word ( subject , ( position + query . len ( ) ) - 1 ) ; let score = score_quality ( query . len ( ) , subject . len ( ) , score_pattern ( query . len ( ) , query . len ( ) , same_case , is_start , is_end ) , position as f32 , ) ; let matches : Vec < usize > = ( position .. ( position + query . len ( ) ) ) . collect ( ) ; Some ( ExactMatchResult :: new ( score , matches ) ) }
Calculate the score of an exact match, if any
Calculate the score of an exact match if any
query
&Query
subject
&Text