fn parse_objsense_section<'a, L: Iterator<Item = FileLocation<'a>>>(
    lines: &mut L,
) -> ParseResult<Objective> {
    match lines.next() {
        None => Err(ParseError::new("No line to read, is the program more than a name?")),
        Some((number, line)) => {
            match line.trim_end() {
                // The default: OBJSENSE is not mentioned and we minimize.
                "ROWS" => Ok(Objective::Minimize),
                "OBJSENSE" => {
                    match lines.next() {
                        None => Err(ParseError::new("Program can't end in the OBJSENSE section.")),
                        Some((number, line)) => {
                            // Throw away the next line, who's contents are "ROWS", check to be sure
                            if !matches!(lines.next(), Some((_, line)) if line.starts_with("ROWS")) {
                                return Err(ParseError::new("Expected the ROWS section next."));
                            }

                            match line.trim_end() {
                                "  MINIMIZE" | "  MIN" => Ok(Objective::Minimize),
                                "  MAXIMIZE" | "  MAX" => Ok(Objective::Maximize),
                                _ => Err(ParseError::with_location(
                                    format!("Can't read objective {}", line.trim_end()),
                                    (number, line),
                                )),
                            }
                        }
                    }
                },
                _ => Err(ParseError::with_location(
                    format!("Line contents \"{}\" were unexpected", line),
                    (number, line),
                )),
            }
        }
    }
}
/// Try to read the objective direction and consume the rows section indicator.
///
/// # Arguments
///
/// `lines`: Iterator yielding meaningful program lines.
///
/// # Errors
///
/// If the iterator is empty, or the next lines don't pretty much look like
/// ```compile_fail
/// OBJSENSE
///   MAXIMIZE
/// ```
/// where it is allowed to abbreviate the direction to the first three characters.
Try to read the objective direction and consume the rows section indicator.
Try to read the objective direction and consume the rows section indicator .
fn parse_objsense_section<'a, L: Iterator<Item = FileLocation<'a>>>(
    lines: &mut L,
) -> ParseResult<Objective> {
    match lines.next() {
        None => Err(ParseError::new("No line to read, is the program more than a name?")),
        Some((number, line)) => {
            match line.trim_end() {
                // The default: OBJSENSE is not mentioned and we minimize.
                "ROWS" => Ok(Objective::Minimize),
                "OBJSENSE" => {
                    match lines.next() {
                        None => Err(ParseError::new("Program can't end in the OBJSENSE section.")),
                        Some((number, line)) => {
                            // Throw away the next line, who's contents are "ROWS", check to be sure
                            if !matches!(lines.next(), Some((_, line)) if line.starts_with("ROWS")) {
                                return Err(ParseError::new("Expected the ROWS section next."));
                            }
                            match line.trim_end() {
                                "  MINIMIZE" | "  MIN" => Ok(Objective::Minimize),
                                "  MAXIMIZE" | "  MAX" => Ok(Objective::Maximize),
                                _ => Err(ParseError::with_location(
                                    format!("Can't read objective {}", line.trim_end()),
                                    (number, line),
                                )),
                            }
                        }
                    }
                },
                _ => Err(ParseError::with_location(
                    format!("Line contents \"{}\" were unexpected", line),
                    (number, line),
                )),
            }
        }
    }
}
fn parse_objsense_section < ' a , L : Iterator < Item = FileLocation < ' a > > > ( lines : & mut L , ) -> ParseResult < Objective > { match lines . next ( ) { None => Err ( ParseError :: new ( " " ) ) , Some ( ( number , line ) ) => { match line . trim_end ( ) { // The default: OBJSENSE is not mentioned and we minimize. " " => Ok ( Objective :: Minimize ) , " " => { match lines . next ( ) { None => Err ( ParseError :: new ( " " ) ) , Some ( ( number , line ) ) => { // Throw away the next line, who's contents are "ROWS", check to be sure if ! matches ! ( lines next ( ) Some ( ( line ) ) if line starts_with ( " " ) ) { return Err ( ParseError :: new ( " " ) ) ; } match line . trim_end ( ) { " " | " " => Ok ( Objective :: Minimize ) , " " | " " => Ok ( Objective :: Maximize ) , _ => Err ( ParseError :: with_location ( format ! ( " " line trim_end ( ) ) , ( number , line ) , ) ) , } } } } , _ => Err ( ParseError :: with_location ( format ! ( " \" \" " line ) , ( number , line ) , ) ) , } } } }
Try to read the objective direction and consume the rows section indicator.
Try to read the objective direction and consume the rows section indicator .
lines
&mut L
lines
&mut L
errors
If the iterator is empty, or the next lines don't pretty much look like
```compile_fail
OBJSENSE
MAXIMIZE
```
where it is allowed to abbreviate the direction to the first three characters.
If the iterator is empty or the next lines don ' t pretty much look like ` ` ` compile_fail OBJSENSE MAXIMIZE ` ` ` where it is allowed to abbreviate the direction to the first three characters .