fn expect_token(
    expected: &[TokenKind],
    token_stream: &mut TokenStream<Lexer>,
    diagnostics: &mut Diagnostics,
) -> Result<Token<TokenKind>, ParseError> {
    let current = token_stream.current().map(Clone::clone);
    match current {
        Ok(token) => {
            if expected.contains(&token.kind) {
                token_stream.next(diagnostics);
                Ok(token)
            } else {
                diagnostics.raise(MismatchedToken {
                    expected: expected.to_vec(),
                    found: token,
                });
                Err(ParseError)
            }
        },
        Err(_) => {
            token_stream.next(diagnostics);
            Err(ParseError)
        },
    }
}
/// Expects a set of tokens. If the current token is not in the set, an error is
/// raised.
Expects a set of tokens. If the current token is not in the set, an error is
raised.
Expects a set of tokens . If the current token is not in the set an error is raised .
fn expect_token(
    expected: &[TokenKind],
    token_stream: &mut TokenStream<Lexer>,
    diagnostics: &mut Diagnostics,
) -> Result<Token<TokenKind>, ParseError> {
    let current = token_stream.current().map(Clone::clone);
    match current {
        Ok(token) => {
            if expected.contains(&token.kind) {
                token_stream.next(diagnostics);
                Ok(token)
            } else {
                diagnostics.raise(MismatchedToken {
                    expected: expected.to_vec(),
                    found: token,
                });
                Err(ParseError)
            }
        },
        Err(_) => {
            token_stream.next(diagnostics);
            Err(ParseError)
        },
    }
}
fn expect_token ( expected : & [ TokenKind ] , token_stream : & mut TokenStream < Lexer > , diagnostics : & mut Diagnostics , ) -> Result < Token < TokenKind > , ParseError > { let current = token_stream . current ( ) . map ( Clone :: clone ) ; match current { Ok ( token ) => { if expected . contains ( & token . kind ) { token_stream . next ( diagnostics ) ; Ok ( token ) } else { diagnostics . raise ( MismatchedToken { expected : expected . to_vec ( ) , found : token , } ) ; Err ( ParseError ) } } , Err ( _ ) => { token_stream . next ( diagnostics ) ; Err ( ParseError ) } , } }
Expects a set of tokens.
Expects a set of tokens .
expected
&[TokenKind]
token_stream
&mut TokenStream<Lexer>
diagnostics
&mut Diagnostics
expected
&[TokenKind]
token_stream
&mut TokenStream<Lexer>
diagnostics
&mut Diagnostics