Struct tokenizer_lib::BufferedTokenQueue
source · [−]pub struct BufferedTokenQueue<T: TokenTrait, TData> { /* private fields */ }
Expand description
A queue which can be used as a sender and reader. Use this for buffering all the tokens before reading
Implementations
sourceimpl<T: TokenTrait, TData> BufferedTokenQueue<T, TData>
impl<T: TokenTrait, TData> BufferedTokenQueue<T, TData>
sourcepub fn new() -> Self
pub fn new() -> Self
Constructs a new BufferedTokenQueue
Trait Implementations
sourceimpl<T: TokenTrait, TData> Default for BufferedTokenQueue<T, TData>
impl<T: TokenTrait, TData> Default for BufferedTokenQueue<T, TData>
sourceimpl<T: TokenTrait, TData> TokenReader<T, TData> for BufferedTokenQueue<T, TData>
impl<T: TokenTrait, TData> TokenReader<T, TData> for BufferedTokenQueue<T, TData>
sourcefn peek(&mut self) -> Option<&Token<T, TData>>
fn peek(&mut self) -> Option<&Token<T, TData>>
Returns a reference to next token but does not advance current position
sourcefn scan(
&mut self,
cb: impl FnMut(&T, &TData) -> bool
) -> Option<&Token<T, TData>>
fn scan(
&mut self,
cb: impl FnMut(&T, &TData) -> bool
) -> Option<&Token<T, TData>>
Runs the closure (cb) over upcoming tokens. Passes the value behind the Token to the closure. Will stop and return a reference to the next Token from when the closure returns true. Returns None if scanning finishes before closure returns true. Does not advance the reader. Read more
sourcefn expect_next(
&mut self,
expected_type: T
) -> Result<TData, Option<(T, Token<T, TData>)>>
fn expect_next(
&mut self,
expected_type: T
) -> Result<TData, Option<(T, Token<T, TData>)>>
Tests that next token matches an expected type. Will return error if does not
match. The Ok
value contains the data of the valid token.
Else it will return the Err with the expected token type and the token that did not match Read more
sourceimpl<T: TokenTrait, TData> TokenSender<T, TData> for BufferedTokenQueue<T, TData>
impl<T: TokenTrait, TData> TokenSender<T, TData> for BufferedTokenQueue<T, TData>
Auto Trait Implementations
impl<T, TData> RefUnwindSafe for BufferedTokenQueue<T, TData> where
T: RefUnwindSafe,
TData: RefUnwindSafe,
impl<T, TData> Send for BufferedTokenQueue<T, TData> where
T: Send,
TData: Send,
impl<T, TData> Sync for BufferedTokenQueue<T, TData> where
T: Sync,
TData: Sync,
impl<T, TData> Unpin for BufferedTokenQueue<T, TData> where
T: Unpin,
TData: Unpin,
impl<T, TData> UnwindSafe for BufferedTokenQueue<T, TData> where
T: UnwindSafe,
TData: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more