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 for MacroStream
impl PartialEq for MacroStream
Source§impl Repr for MacroStream
impl Repr for MacroStream
fn repr(&self, name: &str) -> MacroStream
Source§impl ToTokens for MacroStream
impl ToTokens for MacroStream
Source§fn to_tokens(&self, tokens: &mut TokenStream)
fn to_tokens(&self, tokens: &mut TokenStream)
Source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
Source§fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
fn into_token_stream(self) -> TokenStreamwhere
Self: Sized,
impl Eq for MacroStream
impl StructuralPartialEq for MacroStream
Auto Trait Implementations§
impl Freeze for MacroStream
impl RefUnwindSafe for MacroStream
impl !Send for MacroStream
impl !Sync for MacroStream
impl Unpin for MacroStream
impl UnwindSafe for MacroStream
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