fn next(&mut self) -> Option<Self::Item> {
        loop {
            self.skip_ws();
            // we should be at start of a line now
            let c = *self.iter.peek()?;
            if is_vertical_ws(c) {
                // empty line
                self.iter.next();
                continue;
            } else if is_comment(c, self.opts) {
                self.skip_comment();
            } else if c == '[' {
                // section heading
                self.iter.next(); // consume [

                let (line, col) = (self.iter.line, self.iter.col);
                self.skip_ws();

                // better error message before we store the new line and column.
                if self.iter.peek().is_none() {
                    return Some(Err(format!("line {}:{}: expected \"]\"", line, col)));
                }

                // this key can be empty
                match self.parse_key() {
                    Ok(key) => self.section = key.to_string(),
                    Err(e) => return Some(Err(format!("line {}:{}: {}", line, col, e))),
                };

                let (line, col) = (self.iter.line, self.iter.col);
                self.skip_ws();

                if self.iter.next().map_or(true, |c| c != ']') {
                    return Some(Err(format!("line {}:{}: expected \"]\"", line, col)));
                }
                self.skip_comment();
            } else {
                // this should be a key/value pair

                // parse key, prepend it with section name if present
                let key = match self.parse_key() {
                    // this key cannot be empty
                    Ok(key) if key.is_empty() => {
                        return Some(Err(format!(
                            "line {}:{}: expected key",
                            self.iter.line, self.iter.col
                        )))
                    }
                    // do not prepend an empty section
                    Ok(key) if self.section.is_empty() => key,
                    Ok(key) => format!("{}.{}", self.section, key),
                    Err(e) => {
                        return Some(Err(format!(
                            "line {}:{}: {}",
                            self.iter.line, self.iter.col, e
                        )))
                    }
                };

                let (line, col) = (self.iter.line, self.iter.col);
                self.skip_ws();

                if self.iter.next().map_or(true, |c| c != '=') {
                    return Some(Err(format!("line {}:{}: expected \"=\"", line, col)));
                }

                self.skip_ws();

                let value = match self.parse_value() {
                    Ok(key) => key,
                    Err(e) => return Some(Err(e)),
                };

                self.skip_comment();

                break Some(Ok((key, value)));
            }
        }
    }
/// Try to parse until the next key/value pair.
Try to parse until the next key/value pair.
Try to parse until the next key / value pair .
fn next(&mut self) -> Option<Self::Item> {
        loop {
            self.skip_ws();
            // we should be at start of a line now
            let c = *self.iter.peek()?;
            if is_vertical_ws(c) {
                // empty line
                self.iter.next();
                continue;
            } else if is_comment(c, self.opts) {
                self.skip_comment();
            } else if c == '[' {
                // section heading
                self.iter.next(); // consume [
                let (line, col) = (self.iter.line, self.iter.col);
                self.skip_ws();
                // better error message before we store the new line and column.
                if self.iter.peek().is_none() {
                    return Some(Err(format!("line {}:{}: expected \"]\"", line, col)));
                }
                // this key can be empty
                match self.parse_key() {
                    Ok(key) => self.section = key.to_string(),
                    Err(e) => return Some(Err(format!("line {}:{}: {}", line, col, e))),
                };
                let (line, col) = (self.iter.line, self.iter.col);
                self.skip_ws();
                if self.iter.next().map_or(true, |c| c != ']') {
                    return Some(Err(format!("line {}:{}: expected \"]\"", line, col)));
                }
                self.skip_comment();
            } else {
                // this should be a key/value pair
                // parse key, prepend it with section name if present
                let key = match self.parse_key() {
                    // this key cannot be empty
                    Ok(key) if key.is_empty() => {
                        return Some(Err(format!(
                            "line {}:{}: expected key",
                            self.iter.line, self.iter.col
                        )))
                    }
                    // do not prepend an empty section
                    Ok(key) if self.section.is_empty() => key,
                    Ok(key) => format!("{}.{}", self.section, key),
                    Err(e) => {
                        return Some(Err(format!(
                            "line {}:{}: {}",
                            self.iter.line, self.iter.col, e
                        )))
                    }
                };
                let (line, col) = (self.iter.line, self.iter.col);
                self.skip_ws();
                if self.iter.next().map_or(true, |c| c != '=') {
                    return Some(Err(format!("line {}:{}: expected \"=\"", line, col)));
                }
                self.skip_ws();
                let value = match self.parse_value() {
                    Ok(key) => key,
                    Err(e) => return Some(Err(e)),
                };
                self.skip_comment();
                break Some(Ok((key, value)));
            }
        }
    }
fn next ( & mut self ) -> Option < Self :: Item > { loop { self . skip_ws ( ) ; // we should be at start of a line now let c = * self . iter . peek ( ) ? ; if is_vertical_ws ( c ) { // empty line self . iter . next ( ) ; continue ; } else if is_comment ( c , self . opts ) { self . skip_comment ( ) ; } else if c == '[' { // section heading self . iter . next ( ) ; // consume [ let ( line , col ) = ( self . iter . line , self . iter . col ) ; self . skip_ws ( ) ; // better error message before we store the new line and column. if self . iter . peek ( ) . is_none ( ) { return Some ( Err ( format ! ( " \" \" " line col ) ) ) ; } // this key can be empty match self . parse_key ( ) { Ok ( key ) => self . section = key . to_string ( ) , Err ( e ) => return Some ( Err ( format ! ( " " line col e ) ) ) , } ; let ( line , col ) = ( self . iter . line , self . iter . col ) ; self . skip_ws ( ) ; if self . iter . next ( ) . map_or ( true , | c | c != ']' ) { return Some ( Err ( format ! ( " \" \" " line col ) ) ) ; } self . skip_comment ( ) ; } else { // this should be a key/value pair // parse key, prepend it with section name if present let key = match self . parse_key ( ) { // this key cannot be empty Ok ( key ) if key . is_empty ( ) => { return Some ( Err ( format ! ( " " self iter line self iter col ) ) ) } // do not prepend an empty section Ok ( key ) if self . section . is_empty ( ) => key , Ok ( key ) => format ! ( " " self section key ) , Err ( e ) => { return Some ( Err ( format ! ( " " self iter line self iter col e ) ) ) } } ; let ( line , col ) = ( self . iter . line , self . iter . col ) ; self . skip_ws ( ) ; if self . iter . next ( ) . map_or ( true , | c | c != '=' ) { return Some ( Err ( format ! ( " \" \" " line col ) ) ) ; } self . skip_ws ( ) ; let value = match self . parse_value ( ) { Ok ( key ) => key , Err ( e ) => return Some ( Err ( e ) ) , } ; self . skip_comment ( ) ; break Some ( Ok ( ( key , value ) ) ) ; } } }
Try to parse until the next key/value pair.
Try to parse until the next key / value pair .
&mut self
&mut self