fn peek(&mut self) -> ParseResult<&TokenMeta> {
        if self.next.is_none() {
            self.next = self.tokens.next();
            if self.next.is_none() {
                return Err(ErrorKind::EndofTokenStream.into());
            }
        }
        
        // This craziness is needed to finagle a reference in one branch 
        // while advancing the token iterator and taking ownership of the ParserError in the other
        // otherwise the borrow checker will have a heart attack over the immutable borrow in &mut self.
        if self.next.as_ref().unwrap().is_ok() {
            Ok(self.next.as_ref().unwrap().as_ref().unwrap()) // yes, the repetition is required
        } else {
            Err(self.advance().unwrap_err())
        }
    }
// peek() will consume any errors it encounters (i.e. peek() acts like advance() if the next token was a lexer error)
// this is so that we don't have to do a complex map_err() every single time we call self.peek()
peek() will consume any errors it encounters  acts like advance() if the next token was a lexer error)
this is so that we don't have to do a complex map_err() every single time we call self.peek()
peek () will consume any errors it encounters acts like advance () if the next token was a lexer error ) this is so that we don ' t have to do a complex map_err () every single time we call self . peek ()
fn peek(&mut self) -> ParseResult<&TokenMeta> {
        if self.next.is_none() {
            self.next = self.tokens.next();
            if self.next.is_none() {
                return Err(ErrorKind::EndofTokenStream.into());
            }
        }
        // This craziness is needed to finagle a reference in one branch 
        // while advancing the token iterator and taking ownership of the ParserError in the other
        // otherwise the borrow checker will have a heart attack over the immutable borrow in &mut self.
        if self.next.as_ref().unwrap().is_ok() {
            Ok(self.next.as_ref().unwrap().as_ref().unwrap()) // yes, the repetition is required
        } else {
            Err(self.advance().unwrap_err())
        }
    }
fn peek ( & mut self ) -> ParseResult < & TokenMeta > { if self . next . is_none ( ) { self . next = self . tokens . next ( ) ; if self . next . is_none ( ) { return Err ( ErrorKind :: EndofTokenStream . into ( ) ) ; } } // This craziness is needed to finagle a reference in one branch  // while advancing the token iterator and taking ownership of the ParserError in the other // otherwise the borrow checker will have a heart attack over the immutable borrow in &mut self. if self . next . as_ref ( ) . unwrap ( ) . is_ok ( ) { Ok ( self . next . as_ref ( ) . unwrap ( ) . as_ref ( ) . unwrap ( ) ) // yes, the repetition is required } else { Err ( self . advance ( ) . unwrap_err ( ) ) } }
peek() will consume any errors it encounters (i.e.
peek () will consume any errors it encounters ( i . e .
&mut self
&mut self