[−][src]Struct json_peek::lexer::Lexer
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]
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,
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<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
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?
fn into_iter(self) -> I
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
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.
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>,