pub struct Parser { /* private fields */ }Implementations§
Source§impl Parser
impl Parser
Sourcepub fn parse<T: Parse>(self) -> Result<T>
pub fn parse<T: Parse>(self) -> Result<T>
Top-level parse function that parses the input to the proc macro.
Sourcepub fn peek_token(&mut self) -> Option<&TokenTree>
pub fn peek_token(&mut self) -> Option<&TokenTree>
Returns the next token without consuming it, or None if no tokens remain.
Sourcepub fn peek_span(&mut self) -> Option<Span>
pub fn peek_span(&mut self) -> Option<Span>
Returns the span of the next token, or None if no tokens remain.
Sourcepub fn eat_token(&mut self) -> Option<TokenTree>
pub fn eat_token(&mut self) -> Option<TokenTree>
Consumes the next token, returning it; returns None if no tokens remain.
Sourcepub fn eat_token_if(
&mut self,
test: impl Fn(&TokenTree) -> bool,
) -> Option<TokenTree>
pub fn eat_token_if( &mut self, test: impl Fn(&TokenTree) -> bool, ) -> Option<TokenTree>
Tests whether test returns true for the next token and – if so – consumes and returns it;
returns None if no tokens remain.
pub fn eat_map<R>( &mut self, op: impl FnOnce(&TokenTree) -> Option<R>, ) -> Option<R>
pub fn eat_keyword(&mut self, kw: &str) -> Option<()>
pub fn eat_ident(&mut self) -> Option<String>
pub fn eat_punct(&mut self, ch: char) -> Option<Span>
Trait Implementations§
Source§impl From<TokenStream> for Parser
impl From<TokenStream> for Parser
Source§fn from(value: TokenStream) -> Self
fn from(value: TokenStream) -> Self
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for Parser
impl !RefUnwindSafe for Parser
impl !Send for Parser
impl !Sync for Parser
impl Unpin for Parser
impl !UnwindSafe for Parser
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