pub struct RollbackState<T>(pub T);Expand description
A state type that clones and rolls back its contents during a rewind.
This might be useful if you want to use the parser state to, say, count the parsed occurrences of a particular construct.
Ideally, you should try to have the Clone implementation be fairly cheap.
Tuple Fields§
§0: TTrait Implementations§
Source§impl<T: Clone> Clone for RollbackState<T>
impl<T: Clone> Clone for RollbackState<T>
Source§fn clone(&self) -> RollbackState<T>
fn clone(&self) -> RollbackState<T>
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T: Debug> Debug for RollbackState<T>
impl<T: Debug> Debug for RollbackState<T>
Source§impl<T: Default> Default for RollbackState<T>
impl<T: Default> Default for RollbackState<T>
Source§fn default() -> RollbackState<T>
fn default() -> RollbackState<T>
Returns the “default value” for a type. Read more
Source§impl<T> Deref for RollbackState<T>
impl<T> Deref for RollbackState<T>
Source§impl<T> DerefMut for RollbackState<T>
impl<T> DerefMut for RollbackState<T>
Source§impl<T> From<T> for RollbackState<T>
impl<T> From<T> for RollbackState<T>
Source§impl<'src, T: Clone, I: Input<'src>> Inspector<'src, I> for RollbackState<T>
impl<'src, T: Clone, I: Input<'src>> Inspector<'src, I> for RollbackState<T>
Source§type Checkpoint = T
type Checkpoint = T
A type the Inspector can use to revert to a previous state. Read more
Source§fn on_token(&mut self, _: &<I as Input<'src>>::Token)
fn on_token(&mut self, _: &<I as Input<'src>>::Token)
This function is called when a new token is read from the input stream.
Source§fn on_save<'parse>(&self, _: &Cursor<'src, 'parse, I>) -> Self::Checkpoint
fn on_save<'parse>(&self, _: &Cursor<'src, 'parse, I>) -> Self::Checkpoint
This function is called when a combinator saves the current state of the parse.
Source§fn on_rewind<'parse>(
&mut self,
cp: &Checkpoint<'src, 'parse, I, Self::Checkpoint>,
)
fn on_rewind<'parse>( &mut self, cp: &Checkpoint<'src, 'parse, I, Self::Checkpoint>, )
This function is called when a combinator rewinds to an earlier state of the parser. Read more
impl<T: Copy> Copy for RollbackState<T>
Auto Trait Implementations§
impl<T> Freeze for RollbackState<T>where
T: Freeze,
impl<T> RefUnwindSafe for RollbackState<T>where
T: RefUnwindSafe,
impl<T> Send for RollbackState<T>where
T: Send,
impl<T> Sync for RollbackState<T>where
T: Sync,
impl<T> Unpin for RollbackState<T>where
T: Unpin,
impl<T> UnwindSafe for RollbackState<T>where
T: UnwindSafe,
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
Source§impl<'p, T> Seq<'p, T> for T
impl<'p, T> Seq<'p, T> for T
Source§impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
Source§fn with_span(self, span: S) -> S::Spanned
fn with_span(self, span: S) -> S::Spanned
Invokes
WrappingSpan::make_wrapped to wrap an AST node in a span.