fn find_hex_strings_longer_than(string: &str, max_len: usize) -> Vec<SubstringSpec> {
    let mut ranges_to_remove = Vec::new();
    let mut start_index = 0;
    let mut contiguous_hex_count = 0;

    // Record all large hex-strings' start positions and lengths.
    for (index, char) in string.char_indices() {
        if char.is_ascii_hexdigit() {
            if contiguous_hex_count == 0 {
                // This is the start of a new hex-string.
                start_index = index;
            }
            contiguous_hex_count += 1;
        } else if contiguous_hex_count != 0 {
            // This is the end of a hex-string: if it's too long, record it.
            if contiguous_hex_count > max_len {
                ranges_to_remove.push(SubstringSpec::new(start_index, contiguous_hex_count));
            }
            contiguous_hex_count = 0;
        }
    }
    // If the string contains a large hex-string at the end, record it now.
    if contiguous_hex_count > max_len {
        ranges_to_remove.push(SubstringSpec::new(start_index, contiguous_hex_count));
    }
    ranges_to_remove
}
/// Searches the given string for all occurrences of hex substrings
/// that are longer than the specified `max_len`.
Searches the given string for all occurrences of hex substrings
that are longer than the specified `max_len`.
Searches the given string for all occurrences of hex substrings that are longer than the specified ` max_len ` .
fn find_hex_strings_longer_than(string: &str, max_len: usize) -> Vec<SubstringSpec> {
    let mut ranges_to_remove = Vec::new();
    let mut start_index = 0;
    let mut contiguous_hex_count = 0;
    // Record all large hex-strings' start positions and lengths.
    for (index, char) in string.char_indices() {
        if char.is_ascii_hexdigit() {
            if contiguous_hex_count == 0 {
                // This is the start of a new hex-string.
                start_index = index;
            }
            contiguous_hex_count += 1;
        } else if contiguous_hex_count != 0 {
            // This is the end of a hex-string: if it's too long, record it.
            if contiguous_hex_count > max_len {
                ranges_to_remove.push(SubstringSpec::new(start_index, contiguous_hex_count));
            }
            contiguous_hex_count = 0;
        }
    }
    // If the string contains a large hex-string at the end, record it now.
    if contiguous_hex_count > max_len {
        ranges_to_remove.push(SubstringSpec::new(start_index, contiguous_hex_count));
    }
    ranges_to_remove
}
fn find_hex_strings_longer_than ( string : & str , max_len : usize ) -> Vec < SubstringSpec > { let mut ranges_to_remove = Vec :: new ( ) ; let mut start_index = 0 ; let mut contiguous_hex_count = 0 ; // Record all large hex-strings' start positions and lengths. for ( index , char ) in string . char_indices ( ) { if char . is_ascii_hexdigit ( ) { if contiguous_hex_count == 0 { // This is the start of a new hex-string. start_index = index ; } contiguous_hex_count += 1 ; } else if contiguous_hex_count != 0 { // This is the end of a hex-string: if it's too long, record it. if contiguous_hex_count > max_len { ranges_to_remove . push ( SubstringSpec :: new ( start_index , contiguous_hex_count ) ) ; } contiguous_hex_count = 0 ; } } // If the string contains a large hex-string at the end, record it now. if contiguous_hex_count > max_len { ranges_to_remove . push ( SubstringSpec :: new ( start_index , contiguous_hex_count ) ) ; } ranges_to_remove }
Searches the given string for all occurrences of hex substrings
that are longer than the specified `max_len`.
Searches the given string for all occurrences of hex substrings that are longer than the specified ` max_len ` .
string
&str
max_len
usize
string
&str
max_len
usize