pub trait Token: Debug {
Show 13 methods
// Required methods
fn token_type(&self) -> i32;
fn channel(&self) -> i32;
fn start(&self) -> usize;
fn stop(&self) -> usize;
fn token_index(&self) -> isize;
fn line(&self) -> usize;
fn column(&self) -> usize;
fn text(&self) -> Option<&str>;
fn source_name(&self) -> &str;
// Provided methods
fn interval(&self) -> TextInterval { ... }
fn start_byte(&self) -> usize { ... }
fn stop_byte(&self) -> usize { ... }
fn byte_span(&self) -> Range<usize> { ... }
}Required Methods§
fn token_type(&self) -> i32
fn channel(&self) -> i32
Sourcefn stop(&self) -> usize
fn stop(&self) -> usize
Zero-based absolute inclusive stop index measured in Unicode scalar values.
fn token_index(&self) -> isize
Sourcefn column(&self) -> usize
fn column(&self) -> usize
Zero-based source column where the token starts, measured in Unicode
scalar values from the start of line.
fn text(&self) -> Option<&str>
fn source_name(&self) -> &str
Provided Methods§
fn interval(&self) -> TextInterval
Sourcefn start_byte(&self) -> usize
fn start_byte(&self) -> usize
Zero-based absolute start offset measured in UTF-8 bytes.
The default implementation treats the character index as a byte offset, which is exact for ASCII and preserves compatibility for token implementations that do not expose source byte bounds.
Sourcefn stop_byte(&self) -> usize
fn stop_byte(&self) -> usize
Zero-based exclusive end offset measured in UTF-8 bytes.
Unlike Self::stop, this is exclusive so
token.start_byte()..token.stop_byte() can slice the original UTF-8
source when the token carries source byte bounds. The default
implementation treats character indices as byte offsets.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".