fn find_delim(encoding: Encoding, data: &[u8], index: usize) -> Option<usize> {
    let mut i = index;
    match encoding {
        Encoding::Latin1 | Encoding::UTF8 => {
            if i >= data.len() {
                return None;
            }

            for c in data[i..].iter() {
                if *c == 0 {
                    break;
                }
                i += 1;
            }

            if i == data.len() {
                // delimiter was not found
                return None;
            }

            Some(i)
        }
        Encoding::UTF16 | Encoding::UTF16BE => {
            while i + 1 < data.len() && (data[i] != 0 || data[i + 1] != 0) {
                i += 2;
            }

            if i + 1 >= data.len() {
                // delimiter was not found
                return None;
            }

            Some(i)
        }
    }
}
/// Returns the index of the first delimiter for the specified encoding.
Returns the index of the first delimiter for the specified encoding.
Returns the index of the first delimiter for the specified encoding .
fn find_delim(encoding: Encoding, data: &[u8], index: usize) -> Option<usize> {
    let mut i = index;
    match encoding {
        Encoding::Latin1 | Encoding::UTF8 => {
            if i >= data.len() {
                return None;
            }
            for c in data[i..].iter() {
                if *c == 0 {
                    break;
                }
                i += 1;
            }
            if i == data.len() {
                // delimiter was not found
                return None;
            }
            Some(i)
        }
        Encoding::UTF16 | Encoding::UTF16BE => {
            while i + 1 < data.len() && (data[i] != 0 || data[i + 1] != 0) {
                i += 2;
            }
            if i + 1 >= data.len() {
                // delimiter was not found
                return None;
            }
            Some(i)
        }
    }
}
fn find_delim ( encoding : Encoding , data : & [ u8 ] , index : usize ) -> Option < usize > { let mut i = index ; match encoding { Encoding :: Latin1 | Encoding :: UTF8 => { if i >= data . len ( ) { return None ; } for c in data [ i .. ] . iter ( ) { if * c == 0 { break ; } i += 1 ; } if i == data . len ( ) { // delimiter was not found return None ; } Some ( i ) } Encoding :: UTF16 | Encoding :: UTF16BE => { while i + 1 < data . len ( ) && ( data [ i ] != 0 || data [ i + 1 ] != 0 ) { i += 2 ; } if i + 1 >= data . len ( ) { // delimiter was not found return None ; } Some ( i ) } } }
Returns the index of the first delimiter for the specified encoding.
Returns the index of the first delimiter for the specified encoding .
encoding
Encoding
data
&[u8]
index
usize
encoding
Encoding
data
&[u8]
index
usize