/// Peek at a token not yet consumed. This function merely returns a
/// reference to said token. Use `pop()` to advance the lexer.
Peek at a token not yet consumed. This function merely returns a
reference to said token. Use `pop()` to advance the lexer.
Peek at a token not yet consumed . This function merely returns a reference to said token . Use ` pop () ` to advance the lexer .
pub fn peek<'td>(&mut self, offset: usize) -> DiagResult<'td, &T> {
        // Fill the buffer up to the offset that should be peeked at. If an Eof is
        // encountered beforehand, set the `done` flag and abort.
        while !self.done && self.buffer.len() <= offset {
            let token = self.inner.next_token()?;
            if token == self.eof {
                self.done = true;
            }
            self.buffer.push_back(token);
        }
        // Return the token at the requested offset, or the Eof token if the
        // offset lies beyond the end of the stream.
        Ok(self.buffer.get(offset).unwrap_or(&self.eof))
        // if offset < self.buffer.len() {
        // } else {
        //  Ok(self.eof.clone())
        // }
    }
pub fn peek < ' td > ( & mut self , offset : usize ) -> DiagResult < ' td , & T > { // Fill the buffer up to the offset that should be peeked at. If an Eof is // encountered beforehand, set the `done` flag and abort. while ! self . done && self . buffer . len ( ) <= offset { let token = self . inner . next_token ( ) ? ; if token == self . eof { self . done = true ; } self . buffer . push_back ( token ) ; } // Return the token at the requested offset, or the Eof token if the // offset lies beyond the end of the stream. Ok ( self . buffer . get ( offset ) . unwrap_or ( & self . eof ) ) // if offset < self.buffer.len() { // } else { //  Ok(self.eof.clone()) // } }
Peek at a token not yet consumed.
Peek at a token not yet consumed .
&mut self
offset
usize