[][src]Struct json_peek::Token

pub struct Token<'a> {
    pub span: Span,
    pub kind: TokenKind,
    // some fields omitted
}

A single point of string that represent a useful symbol for Parser to use

Fields

span: Spankind: TokenKind

Methods

impl<'a> Token<'a>[src]

pub const fn new(span: Span, source: &'a str, kind: TokenKind) -> Token<'a>[src]

pub const fn new_number(span: Span, source: &'a str) -> Token<'a>[src]

pub const fn new_symbol(span: Span, source: &'a str) -> Token<'a>[src]

pub const fn new_string(span: Span, source: &'a str) -> Token<'a>[src]

pub const fn new_identifier(span: Span, source: &'a str) -> Token<'a>[src]

pub const fn new_unknown(span: Span, source: &'a str) -> Token<'a>[src]

pub fn value(&self) -> &str[src]

Get a string reprsentation of what Token is pointing to

pub fn trim(&self, offset: usize) -> Token<'a>[src]

See Span::trim()

let token = Token::test_identifier("[hello_world!]");
 
assert_eq!(token.trim(1), Token::test_identifier("hello_world!"));
let token = Token::test_identifier("()");
 
assert_eq!(token.trim(1), Token::test_identifier(""));

pub const fn test(value: &'a str, kind: TokenKind) -> Token<'a>[src]

Create "test" Token which is use inside a unit test to easily create a mock Token

pub const fn test_symbol(value: &'a str) -> Token<'a>[src]

pub const fn test_string(value: &'a str) -> Token<'a>[src]

pub const fn test_number(value: &'a str) -> Token<'a>[src]

pub const fn test_identifier(value: &'a str) -> Token<'a>[src]

pub const fn test_unknown(value: &'a str) -> Token<'a>[src]

Trait Implementations

impl<'a> Clone for Token<'a>[src]

impl<'a> Copy for Token<'a>[src]

impl<'_> Debug for Token<'_>[src]

impl<'_> Display for Token<'_>[src]

impl<'a> Eq for Token<'a>[src]

impl<'_> From<Token<'_>> for Literal[src]

impl<'a> From<Token<'a>> for Option<Value>[src]

impl<'_> Into<String> for Token<'_>[src]

impl<'_> Into<f64> for Token<'_>[src]

impl<'_> PartialEq<Token<'_>> for Token<'_>[src]

impl<'a> PartialEq<char> for Token<'a>[src]

impl<'a> StructuralEq for Token<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Token<'a>

impl<'a> Send for Token<'a>

impl<'a> Sync for Token<'a>

impl<'a> Unpin for Token<'a>

impl<'a> UnwindSafe for Token<'a>

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> ToString for T where
    T: Display + ?Sized
[src]

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.