[][src]Struct json_peek::lexer::Lexer

pub struct Lexer<'a> { /* fields omitted */ }

A Token Lexer which take string and convert it into a list of Token

let content = r#"{"foo": 1}"#;
let lexer = Lexer::new(content);
 
let tokens = lexer.lex();

You are probably getting tired of bad documentation like this so here's megumin:

Methods

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

pub const fn new(source: &'a str) -> Lexer<'a>[src]

Create Lexer to source

let content = r#"{ "foo": null, "bar": false }"#;
let lexer = Lexer::new(content);
let mut token = lexer.into_iter();

// Note: `Token::test_*()` function create a token without position information cause I'm too lazy to do it
assert_eq!(token.next(), Some(Token::test_symbol("{")));
assert_eq!(token.next(), Some(Token::test_string("foo")));
assert_eq!(token.next(), Some(Token::test_symbol(":")));
assert_eq!(token.next(), Some(Token::test_identifier("null")));
assert_eq!(token.next(), Some(Token::test_symbol(",")));
assert_eq!(token.next(), Some(Token::test_string("bar")));
assert_eq!(token.next(), Some(Token::test_symbol(":")));
assert_eq!(token.next(), Some(Token::test_identifier("false")));
assert_eq!(token.next(), Some(Token::test_symbol("}")));
assert_eq!(token.next(), None);

pub fn lex(self) -> Vec<Token<'a>>[src]

Easily create a Vec of Token

Trait Implementations

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

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

impl<'a> Debug for Lexer<'a>[src]

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

impl<'a> IntoIterator for Lexer<'a>[src]

type Item = Token<'a>

The type of the elements being iterated over.

type IntoIter = LexerIter<'a>

Which kind of iterator are we turning this into?

fn into_iter(self) -> Self::IntoIter[src]

Convert Lexer into iterator of Token.
See: LexerIter

impl<'a> PartialEq<Lexer<'a>> for Lexer<'a>[src]

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

impl<'a> StructuralPartialEq for Lexer<'a>[src]

Auto Trait Implementations

impl<'a> RefUnwindSafe for Lexer<'a>

impl<'a> Send for Lexer<'a>

impl<'a> Sync for Lexer<'a>

impl<'a> Unpin for Lexer<'a>

impl<'a> UnwindSafe for Lexer<'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<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

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.