Struct lib_ruby_parser::Token[][src]

#[repr(C)]pub struct Token {
    pub token_type: i32,
    pub token_value: Bytes,
    pub loc: LocPtr,
    pub lex_state_before: LexState,
    pub lex_state_after: LexState,
}

A token that is emitted by a lexer and consumed by a parser

Fields

token_type: i32

Numeric representation of the token type, e.g. 42 (for example) for tINTEGER

token_value: Bytes

Value of the token, e.g “42” for 42

loc: LocPtr

Location of the token

lex_state_before: LexState

Lex state before reading the token

lex_state_after: LexState

Lex state after reading the token

Implementations

impl Token[src]

pub fn as_bytes(&self) -> &[u8][src]

Returns a byte array of the token value

pub fn as_bytes_mut(&mut self) -> &mut [u8][src]

Returns a mut byte array of the token value

pub fn into_bytes(self) -> List<u8>[src]

Consumes a token and returns an owned byte array of the token value

pub fn as_str_lossy(&self) -> Result<&str, Utf8Error>[src]

Converts token value into &str

pub fn to_string_lossy(&self) -> String[src]

Converts token to a string, replaces unknown chars to U+FFFD

pub fn to_string(&self) -> Result<String, FromUtf8Error>[src]

Converts token to a string

pub fn into_string(self) -> Result<String, FromUtf8Error>[src]

Consumes a token and converts it into a string

Trait Implementations

impl Clone for Token[src]

impl Debug for Token[src]

Auto Trait Implementations

impl RefUnwindSafe for Token

impl Send for Token

impl Sync for Token

impl Unpin for Token

impl UnwindSafe for Token

Blanket Implementations

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

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

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

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

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

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

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.

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.