fn next_word(&self) -> Result<(Substr<'a>, usize)> {
        if self.pos == self.buf.len() {
            return Err(PdfError::EOF);
        }
        let mut pos = self.skip_whitespace(self.pos)?;
        while self.buf.get(pos) == Some(&b'%') {
            pos += 1;
            if let Some(off) = self.buf[pos..].iter().position(|&b| b == b'\n') {
                pos += off+1;
            }
            
            // Move away from eventual whitespace
            pos = self.skip_whitespace(pos)?;
        }
        
        let start_pos = pos;

        // If first character is delimiter, this lexeme only contains that character.
        //  - except << and >> which go together, and / which marks the start of a
        // name token.
        if self.is_delimiter(pos) {
            if self.buf[pos] == b'/' {
                pos = self.advance_pos(pos)?;
                while !self.is_whitespace(pos) && !self.is_delimiter(pos) {
                    pos = self.advance_pos(pos)?;
                }
                return Ok((self.new_substr(start_pos..pos), pos));
            }

            if let Some(slice) = self.buf.get(pos..=pos+1) {
                if slice == b"<<" || slice == b">>" {
                    pos = self.advance_pos(pos)?;
                }
            }

            pos = self.advance_pos(pos)?;
            return Ok((self.new_substr(start_pos..pos), pos));
        }

        // Read to past the end of lexeme
        while !self.is_whitespace(pos) && !self.is_delimiter(pos) {
            pos = self.advance_pos(pos)?;
        }
        let result = self.new_substr(start_pos..pos);

        // Move away from whitespace again
        //pos = self.skip_whitespace(pos)?;
        Ok((result, pos))
    }
/// Used by next, peek and back - returns substring and new position
/// If forward, places pointer at the next non-whitespace character.
/// If backward, places pointer at the start of the current word.
// TODO ^ backward case is actually not tested or.. thought about that well.
Used by next, peek and back - returns substring and new position
If forward, places pointer at the next non-whitespace character.
If backward, places pointer at the start of the current word.
TODO ^ backward case is actually not tested or.. thought about that well.
Used by next peek and back - returns substring and new position If forward places pointer at the next non - whitespace character . If backward places pointer at the start of the current word . TODO ^ backward case is actually not tested or .. thought about that well .
fn next_word(&self) -> Result<(Substr<'a>, usize)> {
        if self.pos == self.buf.len() {
            return Err(PdfError::EOF);
        }
        let mut pos = self.skip_whitespace(self.pos)?;
        while self.buf.get(pos) == Some(&b'%') {
            pos += 1;
            if let Some(off) = self.buf[pos..].iter().position(|&b| b == b'\n') {
                pos += off+1;
            }
            // Move away from eventual whitespace
            pos = self.skip_whitespace(pos)?;
        }
        let start_pos = pos;
        // If first character is delimiter, this lexeme only contains that character.
        //  - except << and >> which go together, and / which marks the start of a
        // name token.
        if self.is_delimiter(pos) {
            if self.buf[pos] == b'/' {
                pos = self.advance_pos(pos)?;
                while !self.is_whitespace(pos) && !self.is_delimiter(pos) {
                    pos = self.advance_pos(pos)?;
                }
                return Ok((self.new_substr(start_pos..pos), pos));
            }
            if let Some(slice) = self.buf.get(pos..=pos+1) {
                if slice == b"<<" || slice == b">>" {
                    pos = self.advance_pos(pos)?;
                }
            }
            pos = self.advance_pos(pos)?;
            return Ok((self.new_substr(start_pos..pos), pos));
        }
        // Read to past the end of lexeme
        while !self.is_whitespace(pos) && !self.is_delimiter(pos) {
            pos = self.advance_pos(pos)?;
        }
        let result = self.new_substr(start_pos..pos);
        // Move away from whitespace again
        //pos = self.skip_whitespace(pos)?;
        Ok((result, pos))
    }
fn next_word ( & self ) -> Result < ( Substr < ' a > , usize ) > { if self . pos == self . buf . len ( ) { return Err ( PdfError :: EOF ) ; } let mut pos = self . skip_whitespace ( self . pos ) ? ; while self . buf . get ( pos ) == Some ( & b'%' ) { pos += 1 ; if let Some ( off ) = self . buf [ pos .. ] . iter ( ) . position ( | & b | b == b'\n' ) { pos += off + 1 ; } // Move away from eventual whitespace pos = self . skip_whitespace ( pos ) ? ; } let start_pos = pos ; // If first character is delimiter, this lexeme only contains that character. //  - except << and >> which go together, and / which marks the start of a // name token. if self . is_delimiter ( pos ) { if self . buf [ pos ] == b'/' { pos = self . advance_pos ( pos ) ? ; while ! self . is_whitespace ( pos ) && ! self . is_delimiter ( pos ) { pos = self . advance_pos ( pos ) ? ; } return Ok ( ( self . new_substr ( start_pos .. pos ) , pos ) ) ; } if let Some ( slice ) = self . buf . get ( pos ..= pos + 1 ) { if slice == b" " || slice == b" " { pos = self . advance_pos ( pos ) ? ; } } pos = self . advance_pos ( pos ) ? ; return Ok ( ( self . new_substr ( start_pos .. pos ) , pos ) ) ; } // Read to past the end of lexeme while ! self . is_whitespace ( pos ) && ! self . is_delimiter ( pos ) { pos = self . advance_pos ( pos ) ? ; } let result = self . new_substr ( start_pos .. pos ) ; // Move away from whitespace again //pos = self.skip_whitespace(pos)?; Ok ( ( result , pos ) ) }
Used by next, peek and back - returns substring and new position
If forward, places pointer at the next non-whitespace character.
Used by next peek and back - returns substring and new position If forward places pointer at the next non - whitespace character .
&self
&self