Skip to main content

Token

Trait Token 

Source
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§

Source

fn token_type(&self) -> i32

Source

fn channel(&self) -> i32

Source

fn start(&self) -> usize

Zero-based absolute start index measured in Unicode scalar values.

Source

fn stop(&self) -> usize

Zero-based absolute inclusive stop index measured in Unicode scalar values.

Source

fn token_index(&self) -> isize

Source

fn line(&self) -> usize

One-based source line where the token starts.

Source

fn column(&self) -> usize

Zero-based source column where the token starts, measured in Unicode scalar values from the start of line.

Source

fn text(&self) -> Option<&str>

Source

fn source_name(&self) -> &str

Provided Methods§

Source

fn interval(&self) -> TextInterval

Source

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.

Source

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.

Source

fn byte_span(&self) -> Range<usize>

Zero-based UTF-8 byte span for the token text.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§