fn sequence_position(query: &Query, subject: &Text, skip: usize) -> Option<(usize, usize)> {
    let mut query_iter = query.lowercase_iter().enumerate();
    let mut subject_iter = subject.lowercase_iter().enumerate().skip(skip);

    let mut sequence = false;
    let mut position = 0;
    let mut same_case = 0;

    while let Some((qindex, query_grapheme)) = query_iter.next() {
        let (index, subject_grapheme) = subject_iter.next()?;

        if query_grapheme == subject_grapheme {
            if !sequence {
                position = index;
            }
            sequence = true;

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

            // rewind the iterator
            query_iter = query.lowercase_iter().enumerate();
        }
    }

    Some((position, same_case))
}
/// Get the position of the exact sequence of Query contained in Subject, if any
/// It also returns the number of same case graphemes in the sequence
Get the position of the exact sequence of Query contained in Subject, if any
It also returns the number of same case graphemes in the sequence
Get the position of the exact sequence of Query contained in Subject if any It also returns the number of same case graphemes in the sequence
fn sequence_position(query: &Query, subject: &Text, skip: usize) -> Option<(usize, usize)> {
    let mut query_iter = query.lowercase_iter().enumerate();
    let mut subject_iter = subject.lowercase_iter().enumerate().skip(skip);
    let mut sequence = false;
    let mut position = 0;
    let mut same_case = 0;
    while let Some((qindex, query_grapheme)) = query_iter.next() {
        let (index, subject_grapheme) = subject_iter.next()?;
        if query_grapheme == subject_grapheme {
            if !sequence {
                position = index;
            }
            sequence = true;
            if query.grapheme_at(qindex) == subject.grapheme_at(index) {
                same_case += 1
            }
        } else {
            same_case = 0;
            sequence = false;
            // rewind the iterator
            query_iter = query.lowercase_iter().enumerate();
        }
    }
    Some((position, same_case))
}
fn sequence_position ( query : & Query , subject : & Text , skip : usize ) -> Option < ( usize , usize ) > { let mut query_iter = query . lowercase_iter ( ) . enumerate ( ) ; let mut subject_iter = subject . lowercase_iter ( ) . enumerate ( ) . skip ( skip ) ; let mut sequence = false ; let mut position = 0 ; let mut same_case = 0 ; while let Some ( ( qindex , query_grapheme ) ) = query_iter . next ( ) { let ( index , subject_grapheme ) = subject_iter . next ( ) ? ; if query_grapheme == subject_grapheme { if ! sequence { position = index ; } sequence = true ; if query . grapheme_at ( qindex ) == subject . grapheme_at ( index ) { same_case += 1 } } else { same_case = 0 ; sequence = false ; // rewind the iterator query_iter = query . lowercase_iter ( ) . enumerate ( ) ; } } Some ( ( position , same_case ) ) }
Get the position of the exact sequence of Query contained in Subject, if any
It also returns the number of same case graphemes in the sequence
Get the position of the exact sequence of Query contained in Subject if any It also returns the number of same case graphemes in the sequence
query
&Query
subject
&Text
skip
usize