Skip to main content

Token

Trait Token 

Source
pub trait Token: Debug {
Show 13 methods // Required methods fn token_id(&self) -> TokenId; fn token_type(&self) -> i32; fn channel(&self) -> i32; fn start(&self) -> usize; fn stop(&self) -> usize; fn line(&self) -> usize; fn column(&self) -> usize; fn text(&self) -> Option<&str>; fn source_name(&self) -> &str; fn start_byte(&self) -> Option<usize>; fn stop_byte(&self) -> Option<usize>; // Provided methods fn interval(&self) -> TextInterval { ... } fn byte_span(&self) -> Option<Range<usize>> { ... }
}

Required Methods§

Source

fn token_id(&self) -> TokenId

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

Returns the token’s explicit or source-backed text.

TokenView::text has the same return type and semantics. Use TokenView::text_or_empty only when missing text should intentionally be treated as an empty string.

Source

fn source_name(&self) -> &str

Source

fn start_byte(&self) -> Option<usize>

Zero-based absolute start offset measured in UTF-8 bytes, when available.

Source

fn stop_byte(&self) -> Option<usize>

Zero-based exclusive end offset measured in UTF-8 bytes, when available.

Provided Methods§

Source

fn interval(&self) -> TextInterval

Source

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

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

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T: Token + ?Sized> Token for &T

Source§

fn token_id(&self) -> TokenId

Source§

fn token_type(&self) -> i32

Source§

fn channel(&self) -> i32

Source§

fn start(&self) -> usize

Source§

fn stop(&self) -> usize

Source§

fn line(&self) -> usize

Source§

fn column(&self) -> usize

Source§

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

Source§

fn source_name(&self) -> &str

Source§

fn start_byte(&self) -> Option<usize>

Source§

fn stop_byte(&self) -> Option<usize>

Implementors§