pub(crate) fn next_line_position(
    mut input: &[u8],
    expected_fields: usize,
    delimiter: u8,
) -> Option<usize> {
    let mut total_pos = 0;
    if input.is_empty() {
        return None;
    }
    loop {
        let pos = input.iter().position(|b| *b == b'\n')? + 1;
        if input.len() - pos == 0 {
            return None;
        }
        let line = SplitLines::new(&input[pos..], b'\n').next();
        if let Some(line) = line {
            if SplitFields::new(line, delimiter).into_iter().count() == expected_fields {
                return input.get(pos + 1).and_then(|&b| {
                    Option::from({
                        if b == b'\r' {
                            total_pos + pos + 1
                        } else {
                            total_pos + pos
                        }
                    })
                });
            } else {
                input = &input[pos + 1..];
                total_pos += pos + 1;
            }
        } else {
            return None;
        }
    }
}
/// Find the nearest next line position that is not embedded in a String field.
Find the nearest next line position that is not embedded in a String field.
Find the nearest next line position that is not embedded in a String field .
pub(crate) fn next_line_position(
    mut input: &[u8],
    expected_fields: usize,
    delimiter: u8,
) -> Option<usize> {
    let mut total_pos = 0;
    if input.is_empty() {
        return None;
    }
    loop {
        let pos = input.iter().position(|b| *b == b'\n')? + 1;
        if input.len() - pos == 0 {
            return None;
        }
        let line = SplitLines::new(&input[pos..], b'\n').next();
        if let Some(line) = line {
            if SplitFields::new(line, delimiter).into_iter().count() == expected_fields {
                return input.get(pos + 1).and_then(|&b| {
                    Option::from({
                        if b == b'\r' {
                            total_pos + pos + 1
                        } else {
                            total_pos + pos
                        }
                    })
                });
            } else {
                input = &input[pos + 1..];
                total_pos += pos + 1;
            }
        } else {
            return None;
        }
    }
}
pub ( crate ) fn next_line_position ( mut input : & [ u8 ] , expected_fields : usize , delimiter : u8 , ) -> Option < usize > { let mut total_pos = 0 ; if input . is_empty ( ) { return None ; } loop { let pos = input . iter ( ) . position ( | b | * b == b'\n' ) ? + 1 ; if input . len ( ) - pos == 0 { return None ; } let line = SplitLines :: new ( & input [ pos .. ] , b'\n' ) . next ( ) ; if let Some ( line ) = line { if SplitFields :: new ( line , delimiter ) . into_iter ( ) . count ( ) == expected_fields { return input . get ( pos + 1 ) . and_then ( | & b | { Option :: from ( { if b == b'\r' { total_pos + pos + 1 } else { total_pos + pos } } ) } ) ; } else { input = & input [ pos + 1 .. ] ; total_pos += pos + 1 ; } } else { return None ; } } }
Find the nearest next line position that is not embedded in a String field.
Find the nearest next line position that is not embedded in a String field .
input
&[u8]
expected_fields
usize
delimiter
u8
input
&[u8]
expected_fields
usize
delimiter
u8