Skip to main content

Module token

Module token 

Source
Expand description

Token representation, kinds, flags, and binary-search offset lookup.

Structs§

Token
Compact 12-byte lossless lexical token referencing a byte span [start, end) in src.

Enums§

TokenKind
Lexical kind of a Rust source token (edition-independent, context-free).

Constants§

HAS_ERROR
Flag set on a Token when lexical recovery occurred (e.g. unclosed literal or block comment, empty/overlong char literal, missing digits after base/exponent prefix, invalid raw identifier, or unrecognized source character).
JOINT_NEXT
Flag set on a single-character punctuation Token when the immediately following token is also a single-character punctuation token with zero intervening trivia (self.end == next.start).

Functions§

token_at
Finds the index of the token covering byte (token.start <= byte < token.end) using O(log N) binary search over a contiguous or monotonic slice of tokens.