Struct lib_ruby_parser::Token [−][src]
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
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]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,