Token

Trait Token 

Source
pub trait Token: Clone + Debug {
    type TokenID: Into<usize>;

    // Required methods
    fn token_id(&self) -> Self::TokenID;
    fn line_no(&self) -> usize;
}
Expand description

A trait representing a token in lexical analysis or parsing.

Defines the minimal interface for objects treated as tokens, providing a token identifier and its line position in the source.

Required Associated Types§

Source

type TokenID: Into<usize>

The type used to represent token identifiers.

Required Methods§

Source

fn token_id(&self) -> Self::TokenID

Returns the identifier of this token.

Source

fn line_no(&self) -> usize

Returns the line number where this token appears in the source.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§