Struct proc_utils::TokenStream2
source · pub struct TokenStream2 { /* private fields */ }
Expand description
An abstract stream of tokens, or more concretely a sequence of token trees.
This type provides interfaces for iterating over token trees and for collecting token trees into one stream.
Token stream is both the input and output of #[proc_macro]
,
#[proc_macro_attribute]
and #[proc_macro_derive]
definitions.
Implementations§
source§impl TokenStream
impl TokenStream
Trait Implementations§
source§impl Clone for TokenStream
impl Clone for TokenStream
source§fn clone(&self) -> TokenStream
fn clone(&self) -> TokenStream
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for TokenStream
impl Debug for TokenStream
Prints token in a form convenient for debugging.
source§impl Default for TokenStream
impl Default for TokenStream
TokenStream::default()
returns an empty stream,
i.e. this is equivalent with TokenStream::new()
.
source§fn default() -> TokenStream
fn default() -> TokenStream
source§impl Display for TokenStream
impl Display for TokenStream
Prints the token stream as a string that is supposed to be losslessly
convertible back into the same token stream (modulo spans), except for
possibly TokenTree::Group
s with Delimiter::None
delimiters and negative
numeric literals.
source§impl Extend<TokenStream> for TokenStream
impl Extend<TokenStream> for TokenStream
source§fn extend<I>(&mut self, streams: I)where
I: IntoIterator<Item = TokenStream>,
fn extend<I>(&mut self, streams: I)where I: IntoIterator<Item = TokenStream>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl Extend<TokenTree> for TokenStream
impl Extend<TokenTree> for TokenStream
source§fn extend<I>(&mut self, streams: I)where
I: IntoIterator<Item = TokenTree>,
fn extend<I>(&mut self, streams: I)where I: IntoIterator<Item = TokenTree>,
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)source§impl From<TokenStream> for TokenStream
impl From<TokenStream> for TokenStream
source§fn from(inner: TokenStream) -> TokenStream
fn from(inner: TokenStream) -> TokenStream
source§impl From<TokenTree> for TokenStream
impl From<TokenTree> for TokenStream
source§fn from(token: TokenTree) -> TokenStream
fn from(token: TokenTree) -> TokenStream
source§impl FromIterator<TokenStream> for TokenStream
impl FromIterator<TokenStream> for TokenStream
source§fn from_iter<I>(streams: I) -> TokenStreamwhere
I: IntoIterator<Item = TokenStream>,
fn from_iter<I>(streams: I) -> TokenStreamwhere I: IntoIterator<Item = TokenStream>,
source§impl FromIterator<TokenTree> for TokenStream
impl FromIterator<TokenTree> for TokenStream
Collects a number of token trees into a single stream.
source§fn from_iter<I>(streams: I) -> TokenStreamwhere
I: IntoIterator<Item = TokenTree>,
fn from_iter<I>(streams: I) -> TokenStreamwhere I: IntoIterator<Item = TokenTree>,
source§impl FromStr for TokenStream
impl FromStr for TokenStream
Attempts to break the string into tokens and parse those tokens into a token stream.
May fail for a number of reasons, for example, if the string contains unbalanced delimiters or characters not existing in the language.
NOTE: Some errors may cause panics instead of returning LexError
. We
reserve the right to change these errors into LexError
s later.
source§impl IntoIterator for TokenStream
impl IntoIterator for TokenStream
source§impl Parse for TokenStream
impl Parse for TokenStream
fn parse(input: &ParseBuffer<'_>) -> Result<TokenStream, Error>
source§impl ToTokens for TokenStream
impl ToTokens for TokenStream
source§fn to_tokens(&self, dst: &mut TokenStream)
fn to_tokens(&self, dst: &mut TokenStream)
source§fn into_token_stream(self) -> TokenStream
fn into_token_stream(self) -> TokenStream
source§fn to_token_stream(&self) -> TokenStream
fn to_token_stream(&self) -> TokenStream
source§impl TokenStreamExt for TokenStream
impl TokenStreamExt for TokenStream
source§fn append<U>(&mut self, token: U)where
U: Into<TokenTree>,
fn append<U>(&mut self, token: U)where U: Into<TokenTree>,
ToTokens
implementations. Read moresource§fn append_all<I>(&mut self, iter: I)where
I: IntoIterator,
<I as IntoIterator>::Item: ToTokens,
fn append_all<I>(&mut self, iter: I)where I: IntoIterator, <I as IntoIterator>::Item: ToTokens,
ToTokens
implementations. Read moresource§fn append_separated<I, U>(&mut self, iter: I, op: U)where
I: IntoIterator,
<I as IntoIterator>::Item: ToTokens,
U: ToTokens,
fn append_separated<I, U>(&mut self, iter: I, op: U)where I: IntoIterator, <I as IntoIterator>::Item: ToTokens, U: ToTokens,
ToTokens
implementations. Read moresource§fn append_terminated<I, U>(&mut self, iter: I, term: U)where
I: IntoIterator,
<I as IntoIterator>::Item: ToTokens,
U: ToTokens,
fn append_terminated<I, U>(&mut self, iter: I, term: U)where I: IntoIterator, <I as IntoIterator>::Item: ToTokens, U: ToTokens,
ToTokens
implementations. Read moreAuto Trait Implementations§
impl RefUnwindSafe for TokenStream
impl !Send for TokenStream
impl !Sync for TokenStream
impl Unpin for TokenStream
impl UnwindSafe for TokenStream
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> PrettyPrint for Twhere
T: ToTokens,
impl<T> PrettyPrint for Twhere T: ToTokens,
source§fn pretty_print(&self)
fn pretty_print(&self)
ToPretty::to_pretty
but prints to the console instead.source§impl<T> Spanned for Twhere
T: Spanned + ?Sized,
impl<T> Spanned for Twhere T: Spanned + ?Sized,
source§fn span(&self) -> Span
fn span(&self) -> Span
Span
covering the complete contents of this syntax tree
node, or Span::call_site()
if this node is empty.