pub struct TokenCursor {
curr: TokenTreeCursor,
stack: Vec<TokenTreeCursor>,
}Expand description
A TokenStream cursor that produces Tokens. It’s a bit odd that
we (a) lex tokens into a nice tree structure (TokenStream), and then (b)
use this type to emit them as a linear sequence. But a linear sequence is
what the parser expects, for the most part.
Fields§
§curr: TokenTreeCursor§stack: Vec<TokenTreeCursor>Implementations§
Source§impl TokenCursor
impl TokenCursor
pub fn new(stream: TokenStream) -> Self
pub fn next(&mut self) -> (Token, Spacing)
Sourcepub fn look_ahead(&self, n: usize) -> Option<&TokenTree>
pub fn look_ahead(&self, n: usize) -> Option<&TokenTree>
An n of zero is the next token tree in the current token stream; won’t look outside the
current token stream.
Sourcepub fn look_ahead_past_close_delim(&self) -> Option<&TokenTree>
pub fn look_ahead_past_close_delim(&self) -> Option<&TokenTree>
Returns the first token tree (if there is one) past the close delimiter of the enclosing delimited sequence. Panics if we are not within a delimited sequence.
Sourcepub fn clone_enclosing_delim(&self) -> TokenTree
pub fn clone_enclosing_delim(&self) -> TokenTree
Clones the TokenTree::Delimited that we are currently within. Panics if we are not within
a delimited sequence.
Sourcepub fn bump_to_end(&mut self)
pub fn bump_to_end(&mut self)
For skipping to the end of the current sequence, in rare circumstances.
Sourcepub fn parent_delim_and_span(&self) -> Option<(Delimiter, DelimSpan)>
pub fn parent_delim_and_span(&self) -> Option<(Delimiter, DelimSpan)>
Returns details about the parent delimited sequence, if there is one.
Sourcepub fn inlined_next(&mut self) -> (Token, Spacing)
pub fn inlined_next(&mut self) -> (Token, Spacing)
This always-inlined version should only be used on hot code paths.
Trait Implementations§
Source§impl Clone for TokenCursor
impl Clone for TokenCursor
Source§fn clone(&self) -> TokenCursor
fn clone(&self) -> TokenCursor
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl DynSend for TokenCursor
impl DynSync for TokenCursor
impl Freeze for TokenCursor
impl RefUnwindSafe for TokenCursor
impl Send for TokenCursor
impl Sync for TokenCursor
impl Unpin for TokenCursor
impl UnsafeUnpin for TokenCursor
impl UnwindSafe for TokenCursor
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
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> ⓘ
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<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
Source§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 40 bytes