[][src]Struct json_peek::lexer::LexerIter

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

An iterator that generate Token from given &str

You shouldn't manually create this iterator but rather use Lexer instead.

Methods

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

pub const fn new(
    source: &'a str,
    stream: TokenStream<'a>,
    span: Span
) -> LexerIter<'a>
[src]

Manually create new LexerIter

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

Get the current scope that LexerIter can see

pub fn previous_token_is(&self, token: char) -> bool[src]

Shorthand for self.previous_token() == Some(char)

pub fn previous_token(&self) -> Option<char>[src]

Get a char before the current token.

Can be None if this is the beginning of iterator or this is emoji, I really need to make this compatible with UTF-8 /shrug

let mut lexer = Lexer::new("177013").into_iter();
lexer.next();
assert_eq!(lexer.previous_token(), Some('1'));

pub fn lex_until(&mut self, predicate: impl Fn(char, &mut LexerIter) -> bool)[src]

Continue lexing until predicate return false, will include the last item with the result

NOT an inverse of lex_while

pub fn lex_while(&mut self, predicate: impl Fn(char, &mut LexerIter) -> bool)[src]

Continue lexing while predicate return true, will exclude the last item from the result

NOT an inverse of lex_until

Trait Implementations

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

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

impl<'a> From<&'a str> for LexerIter<'a>[src]

impl<'a> Iterator for LexerIter<'a>[src]

type Item = Token<'a>

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a> RefUnwindSafe for LexerIter<'a>

impl<'a> Send for LexerIter<'a>

impl<'a> Sync for LexerIter<'a>

impl<'a> Unpin for LexerIter<'a>

impl<'a> UnwindSafe for LexerIter<'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.