pub struct CaptureCursor<'tokens> { /* private fields */ }Expand description
A read cursor over one normalized captured-token sequence.
The cursor borrows an already bounded capture and advances only after one requested mechanical shape is present. It knows token structure and no declaration vocabulary beyond an exact word the caller asks it to read.
Implementations§
Source§impl<'tokens> CaptureCursor<'tokens>
impl<'tokens> CaptureCursor<'tokens>
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Whether this sequence has no token left to read.
Sourcepub fn fragment<T>(
&mut self,
read: impl FnOnce(&mut Self) -> Result<T, CaptureReadRefusal>,
) -> Result<(CapturedFragment<'tokens>, T), CaptureReadRefusal>
pub fn fragment<T>( &mut self, read: impl FnOnce(&mut Self) -> Result<T, CaptureReadRefusal>, ) -> Result<(CapturedFragment<'tokens>, T), CaptureReadRefusal>
Read one caller-defined shape and retain the exact captured run it consumed.
The callback may consume no token where an empty exact Rust seat is lawful. The returned fragment still belongs to this cursor’s original captured sequence and retains its enclosing group boundary.
§Errors
Returns the callback’s exact typed mechanical refusal without advancing past that refusal.
Sourcepub fn token(
&mut self,
) -> Result<&'tokens CapturedTokenTree, CaptureReadRefusal>
pub fn token( &mut self, ) -> Result<&'tokens CapturedTokenTree, CaptureReadRefusal>
Read any one captured token.
§Errors
Returns a typed missing-token refusal at the current sequence boundary.
Sourcepub fn word(
&mut self,
expected: &str,
) -> Result<&'tokens CapturedTokenTree, CaptureReadRefusal>
pub fn word( &mut self, expected: &str, ) -> Result<&'tokens CapturedTokenTree, CaptureReadRefusal>
Read one exact ordinary word.
A raw identifier does not satisfy this operation because rawness is declaration material.
Use CaptureCursor::identifier where either identifier form is lawful.
§Errors
Returns a typed missing or unexpected-token refusal at the exact available span.
Sourcepub fn identifier(
&mut self,
) -> Result<(&'tokens CapturedTokenTree, &'tokens str), CaptureReadRefusal>
pub fn identifier( &mut self, ) -> Result<(&'tokens CapturedTokenTree, &'tokens str), CaptureReadRefusal>
Read one ordinary or raw identifier token.
The returned token retains which form it carried through CapturedTokenTree::word and CapturedTokenTree::raw_identifier.
§Errors
Returns a typed missing or unexpected-token refusal at the exact available span.
Sourcepub fn number(
&mut self,
) -> Result<(&'tokens CapturedTokenTree, &'tokens str), CaptureReadRefusal>
pub fn number( &mut self, ) -> Result<(&'tokens CapturedTokenTree, &'tokens str), CaptureReadRefusal>
Read one numeric literal spelling.
§Errors
Returns a typed missing or unexpected-token refusal at the exact available span.
Sourcepub fn punctuation(
&mut self,
mark: char,
spacing: CapturedSpacing,
) -> Result<&'tokens CapturedTokenTree, CaptureReadRefusal>
pub fn punctuation( &mut self, mark: char, spacing: CapturedSpacing, ) -> Result<&'tokens CapturedTokenTree, CaptureReadRefusal>
Read one punctuation seat with both character and adjacency stated.
§Errors
Returns a typed missing or unexpected-token refusal at the exact available span.
Sourcepub fn thin_arrow(
&mut self,
) -> Result<[&'tokens CapturedTokenTree; 2], CaptureReadRefusal>
pub fn thin_arrow( &mut self, ) -> Result<[&'tokens CapturedTokenTree; 2], CaptureReadRefusal>
Read the two punctuation seats of ->.
§Errors
Returns the exact first seat that is missing or disagrees.
Sourcepub fn fat_arrow(
&mut self,
) -> Result<[&'tokens CapturedTokenTree; 2], CaptureReadRefusal>
pub fn fat_arrow( &mut self, ) -> Result<[&'tokens CapturedTokenTree; 2], CaptureReadRefusal>
Read the two punctuation seats of =>.
§Errors
Returns the exact first seat that is missing or disagrees.
Sourcepub fn group(
&mut self,
delimiter: CapturedDelimiter,
) -> Result<Self, CaptureReadRefusal>
pub fn group( &mut self, delimiter: CapturedDelimiter, ) -> Result<Self, CaptureReadRefusal>
Read one group and open a cursor over its captured members.
A missing token inside the returned cursor points at this group token, which is the exact source boundary the capture retains for an empty or exhausted group.
§Errors
Returns a typed missing or unexpected-token refusal at the exact available span.
Sourcepub fn trailing_separated<T, const LIMIT: usize>(
self,
separator: char,
read: impl FnMut(&mut Self) -> Result<T, CaptureReadRefusal>,
) -> Result<Bounded<T, LIMIT>, CaptureReadRefusal>
pub fn trailing_separated<T, const LIMIT: usize>( self, separator: char, read: impl FnMut(&mut Self) -> Result<T, CaptureReadRefusal>, ) -> Result<Bounded<T, LIMIT>, CaptureReadRefusal>
Read a sequence whose every member is followed by one standalone separator.
Empty standing is deliberately left to the caller: this operation returns an empty Bounded where the sequence is empty.
The member reader owns one member’s shape and meaning, while this operation owns cursor progress, the separator seat, and the declared member magnitude.
§Errors
Returns the member reader’s refusal, an exact separator refusal, a nonadvancing-reader refusal, or a refusal at the first member beyond LIMIT.
Sourcepub fn finish(self) -> Result<(), CaptureReadRefusal>
pub fn finish(self) -> Result<(), CaptureReadRefusal>
Finish this sequence after every token has been consumed.
§Errors
Returns CaptureReadIssue::InputRemaining at the first unconsumed token.
Trait Implementations§
Source§impl<'tokens> Clone for CaptureCursor<'tokens>
impl<'tokens> Clone for CaptureCursor<'tokens>
Source§fn clone(&self) -> CaptureCursor<'tokens>
fn clone(&self) -> CaptureCursor<'tokens>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more