pub struct TextAccum<'p> { /* private fields */ }Expand description
Utility class for accumulating tokens into a string, keeping a combined span that contains (in theory) all the tokens accumulated. This class is a hack used to bridge our LALRPOP parser, which operates on strings, with the user’s code. What we should really do is modify the LALRPOP parser to operate on tokens directly, but that’s for later.
Implementations§
Source§impl<'p> TextAccum<'p>
impl<'p> TextAccum<'p>
pub fn new(parser: &'p mut Parser, t0: TokenTree) -> Self
Sourcepub fn accum(&mut self) -> Option<TokenTree>
pub fn accum(&mut self) -> Option<TokenTree>
Accumulate next token into the internal buffer and return it.
Sourcepub fn accum_if(
&mut self,
test: impl Fn(&TokenTree) -> bool,
) -> Option<TokenTree>
pub fn accum_if( &mut self, test: impl Fn(&TokenTree) -> bool, ) -> Option<TokenTree>
If the next token passes test, accumulates it into the internal buffer, and returns it.
Sourcepub fn into_accumulated_result(self) -> (String, Span)
pub fn into_accumulated_result(self) -> (String, Span)
Return the string we accumulated.
Auto Trait Implementations§
impl<'p> Freeze for TextAccum<'p>
impl<'p> !RefUnwindSafe for TextAccum<'p>
impl<'p> !Send for TextAccum<'p>
impl<'p> !Sync for TextAccum<'p>
impl<'p> Unpin for TextAccum<'p>
impl<'p> !UnwindSafe for TextAccum<'p>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more