Skip to main content

TextAccum

Struct TextAccum 

Source
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>

Source

pub fn new(parser: &'p mut Parser, t0: TokenTree) -> Self

Source

pub fn accum(&mut self) -> Option<TokenTree>

Accumulate next token into the internal buffer and return it.

Source

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.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.