Struct macros_utils::MacroStream
source · pub struct MacroStream { /* private fields */ }
Expand description
A stream of tokens.
Implementations§
source§impl MacroStream
impl MacroStream
sourcepub fn from_tokens(stream: TokenStream) -> ParseResult<Self>
pub fn from_tokens(stream: TokenStream) -> ParseResult<Self>
Create a MacroStream
from a proc_macro2::TokenStream
.
sourcepub fn peek_at(&self, i: usize) -> Option<&Token>
pub fn peek_at(&self, i: usize) -> Option<&Token>
Peek at the token at the given index in the stream.
sourcepub fn parse<T>(&mut self) -> Result<T, MacrosError>where
T: Parse,
pub fn parse<T>(&mut self) -> Result<T, MacrosError>where T: Parse,
Parse the stream into a type.
sourcepub fn pop_or_err(&mut self) -> Result<Token, ParseError>
pub fn pop_or_err(&mut self) -> Result<Token, ParseError>
Pop a token from the stream, or return an error if the stream is empty.
sourcepub fn peek_or_err(&self) -> Result<&Token, ParseError>
pub fn peek_or_err(&self) -> Result<&Token, ParseError>
Peek at the next token in the stream, or return an error if the stream is empty.
sourcepub fn push_front(&mut self, token: Token)
pub fn push_front(&mut self, token: Token)
Push a token to the front of the stream.
Trait Implementations§
source§impl Clone for MacroStream
impl Clone for MacroStream
source§fn clone(&self) -> MacroStream
fn clone(&self) -> MacroStream
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for MacroStream
impl Debug for MacroStream
source§impl Default for MacroStream
impl Default for MacroStream
source§impl From<TokenStream> for MacroStream
impl From<TokenStream> for MacroStream
source§fn from(stream: TokenStream) -> Self
fn from(stream: TokenStream) -> Self
Converts to this type from the input type.
source§impl PartialEq<MacroStream> for MacroStream
impl PartialEq<MacroStream> for MacroStream
source§fn eq(&self, other: &MacroStream) -> bool
fn eq(&self, other: &MacroStream) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.