Struct relex::Token[][src]

pub struct Token<'a, K: TokenKind> {
    pub kind: K,
    pub start: usize,
    pub end: usize,
    pub text: &'a str,
    pub skip: bool,
    pub next: Option<Box<Token<'a, K>>>,
    pub skipped: Vec<Token<'a, K>>,
    pub captures: Option<Vec<Option<(usize, usize)>>>,
}
Expand description

Represents a detected token

Fields

kind: Kstart: usizeend: usizetext: &'a strskip: boolnext: Option<Box<Token<'a, K>>>

In some cases (viz. when an “unrecognized” token is returned), whatever token comes next is cached here.

skipped: Vec<Token<'a, K>>

The tokens skipped over to get here.

captures: Option<Vec<Option<(usize, usize)>>>

Implementations

impl<'a, K: TokenKind> Token<'a, K>[src]

pub fn new(source: &'a str, kind: K, start: usize, end: usize) -> Token<'a, K>[src]

pub fn from_text(kind: K, text: &'a str, start: usize) -> Token<'a, K>[src]

pub fn eof(source: &'a str) -> Token<'a, K>[src]

pub fn skip(self, skip: bool) -> Self[src]

pub fn skipped(self, skipped: Vec<Token<'a, K>>) -> Self[src]

pub fn next(self, next: Option<Box<Token<'a, K>>>) -> Self[src]

pub fn captures(self, captures: Option<Vec<Option<(usize, usize)>>>) -> Self[src]

pub fn get_capture(&self, idx: usize) -> Option<TokenCapture<'a>>[src]

Trait Implementations

impl<'a, K: Debug + TokenKind> Debug for Token<'a, K>[src]

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<'a, K: PartialEq + TokenKind> PartialEq<Token<'a, K>> for Token<'a, K>[src]

fn eq(&self, other: &Token<'a, K>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &Token<'a, K>) -> bool[src]

This method tests for !=.

impl<'a, K: TokenKind> StructuralPartialEq for Token<'a, K>[src]

Auto Trait Implementations

impl<'a, K> RefUnwindSafe for Token<'a, K> where
    K: RefUnwindSafe

impl<'a, K> Send for Token<'a, K> where
    K: Send

impl<'a, K> Sync for Token<'a, K> where
    K: Sync

impl<'a, K> Unpin for Token<'a, K> where
    K: Unpin

impl<'a, K> UnwindSafe for Token<'a, K> where
    K: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.