MCPcopy Create free account
hub / github.com/astral-sh/ruff / peek2

Method peek2

crates/ruff_python_parser/src/token_source.rs:151–157  ·  view source on GitHub ↗

Returns the next two non-trivia tokens without consuming it. Use [`peek`] to only get the next token. [`peek`]: TokenSource::peek

(&mut self)

Source from the content-addressed store, hash-verified

149 ///
150 /// [`peek`]: TokenSource::peek
151 pub(crate) fn peek2(&mut self) -> (TokenKind, TokenKind) {
152 let checkpoint = self.lexer.checkpoint();
153 let first = self.next_non_trivia_token();
154 let second = self.next_non_trivia_token();
155 self.lexer.rewind(checkpoint);
156 (first, second)
157 }
158
159 /// Bumps the token source to the next non-trivia token.
160 ///

Callers

nothing calls this directly

Calls 3

next_non_trivia_tokenMethod · 0.80
checkpointMethod · 0.45
rewindMethod · 0.45

Tested by

no test coverage detected