fn parse_until_field<'a>(i : &'a str, field : &'a str) -> IResult<&'a str, &'a str> {
    let mut out = i; 
    loop {
        // If the next char is numeric, it means this parser has failed to find the field
        if is_next_tag_x(out, "##XYDATA=") && field != "XYDATA"{
            return Err(nom::Err::Error(nom::error::Error{ input : out, code : nom::error::ErrorKind::Not}));
        }
        // If the next char is not a ##, and not numeric, it should skip to the next line
        if !is_next_char_x(out, '#') {
            out = not_newline(out)?.0;
            continue
        }
        match parse_field(out, field, "##") {
            // This assumes that all errors mean that the field has yet to be found in the header
            // only skips to the next line
            Err(_) => {
                out = not_newline(out)?.0;
            }, Ok(x) => {
                return Ok(x)
            }
        }
    }
}
// Parses through the header until reaching the desired field.
// This assumes that the field is actually in the header.
Parses through the header until reaching the desired field.
This assumes that the field is actually in the header.
Parses through the header until reaching the desired field . This assumes that the field is actually in the header .
fn parse_until_field<'a>(i : &'a str, field : &'a str) -> IResult<&'a str, &'a str> {
    let mut out = i; 
    loop {
        // If the next char is numeric, it means this parser has failed to find the field
        if is_next_tag_x(out, "##XYDATA=") && field != "XYDATA"{
            return Err(nom::Err::Error(nom::error::Error{ input : out, code : nom::error::ErrorKind::Not}));
        }
        // If the next char is not a ##, and not numeric, it should skip to the next line
        if !is_next_char_x(out, '#') {
            out = not_newline(out)?.0;
            continue
        }
        match parse_field(out, field, "##") {
            // This assumes that all errors mean that the field has yet to be found in the header
            // only skips to the next line
            Err(_) => {
                out = not_newline(out)?.0;
            }, Ok(x) => {
                return Ok(x)
            }
        }
    }
}
fn parse_until_field < ' a > ( i : & ' a str , field : & ' a str ) -> IResult < & ' a str , & ' a str > { let mut out = i ; loop { // If the next char is numeric, it means this parser has failed to find the field if is_next_tag_x ( out , " " ) && field != " " { return Err ( nom :: Err :: Error ( nom :: error :: Error { input : out , code : nom :: error :: ErrorKind :: Not } ) ) ; } // If the next char is not a ##, and not numeric, it should skip to the next line if ! is_next_char_x ( out , '#' ) { out = not_newline ( out ) ? . 0 ; continue } match parse_field ( out , field , " " ) { // This assumes that all errors mean that the field has yet to be found in the header // only skips to the next line Err ( _ ) => { out = not_newline ( out ) ? . 0 ; } , Ok ( x ) => { return Ok ( x ) } } } }
Parses through the header until reaching the desired field.
Parses through the header until reaching the desired field .
i
&'a str
field
&'a str
i
&'a str
field
&'a str