fn chomp(
        &mut self,
        kind: TokenKind,
        mut comments: impl FnMut(Comment<'input>),
    ) -> Option<(Token<'input>, Span)> {
        // Look ahead and make sure the next non-comment token is the one we
        // want
        if self.next_kind() != Some(kind) {
            return None;
        }

        while let Some((tok, span)) = self.lexer.next() {
            // We found it!
            if tok.kind() == kind {
                return Some((tok, span));
            }

            if let Token::Comment(body) = tok {
                comments(Comment::new(body, span));
            } else {
                unreachable!(
                    "We should only ever see a {} or comments. Found {:?}",
                    kind, tok
                );
            }
        }

        unreachable!()
    }
/// Look ahead at the next token, advancing and returning the token if it
/// is the correct type (`kind`). Any comments will automatically be added
/// to the block.
Look ahead at the next token, advancing and returning the token if it
is the correct type (`kind`). Any comments will automatically be added
to the block.
Look ahead at the next token advancing and returning the token if it is the correct type ( ` kind ` ) . Any comments will automatically be added to the block .
fn chomp(
        &mut self,
        kind: TokenKind,
        mut comments: impl FnMut(Comment<'input>),
    ) -> Option<(Token<'input>, Span)> {
        // Look ahead and make sure the next non-comment token is the one we
        // want
        if self.next_kind() != Some(kind) {
            return None;
        }
        while let Some((tok, span)) = self.lexer.next() {
            // We found it!
            if tok.kind() == kind {
                return Some((tok, span));
            }
            if let Token::Comment(body) = tok {
                comments(Comment::new(body, span));
            } else {
                unreachable!(
                    "We should only ever see a {} or comments. Found {:?}",
                    kind, tok
                );
            }
        }
        unreachable!()
    }
fn chomp ( & mut self , kind : TokenKind , mut comments : impl FnMut ( Comment < ' input > ) , ) -> Option < ( Token < ' input > , Span ) > { // Look ahead and make sure the next non-comment token is the one we // want if self . next_kind ( ) != Some ( kind ) { return None ; } while let Some ( ( tok , span ) ) = self . lexer . next ( ) { // We found it! if tok . kind ( ) == kind { return Some ( ( tok , span ) ) ; } if let Token :: Comment ( body ) = tok { comments ( Comment :: new ( body , span ) ) ; } else { unreachable ! ( " " kind tok ) ; } } unreachable ! ( ) }
Look ahead at the next token, advancing and returning the token if it
is the correct type (`kind`).
Look ahead at the next token advancing and returning the token if it is the correct type ( ` kind ` ) .
&mut self
kind
TokenKind
comments
impl FnMut(Comment<'input>)
&mut self
kind
TokenKind
comments
impl FnMut(Comment<'input>)