Struct proc_macro2::TokenStream
source · [−]pub struct TokenStream { /* 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
Trait Implementations
sourceimpl Clone for TokenStream
impl Clone for TokenStream
sourcefn clone(&self) -> TokenStream
fn clone(&self) -> TokenStream
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresourceimpl Debug for TokenStream
impl Debug for TokenStream
Prints token in a form convenient for debugging.
sourceimpl Default for TokenStream
impl Default for TokenStream
TokenStream::default()
returns an empty stream,
i.e. this is equivalent with TokenStream::new()
.
sourceimpl 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.
sourceimpl Extend<TokenStream> for TokenStream
impl Extend<TokenStream> for TokenStream
sourcefn extend<I: IntoIterator<Item = TokenStream>>(&mut self, streams: I)
fn extend<I: IntoIterator<Item = TokenStream>>(&mut self, streams: I)
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)sourceimpl Extend<TokenTree> for TokenStream
impl Extend<TokenTree> for TokenStream
sourcefn extend<I: IntoIterator<Item = TokenTree>>(&mut self, streams: I)
fn extend<I: IntoIterator<Item = TokenTree>>(&mut self, streams: I)
sourcefn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)sourcefn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)sourceimpl From<TokenStream> for TokenStream
impl From<TokenStream> for TokenStream
sourcefn from(inner: TokenStream) -> Self
fn from(inner: TokenStream) -> Self
sourceimpl From<TokenStream> for TokenStream
impl From<TokenStream> for TokenStream
sourcefn from(inner: TokenStream) -> Self
fn from(inner: TokenStream) -> Self
sourceimpl From<TokenTree> for TokenStream
impl From<TokenTree> for TokenStream
sourceimpl FromIterator<TokenStream> for TokenStream
impl FromIterator<TokenStream> for TokenStream
sourcefn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self
fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self
sourceimpl FromIterator<TokenTree> for TokenStream
impl FromIterator<TokenTree> for TokenStream
Collects a number of token trees into a single stream.
sourcefn from_iter<I: IntoIterator<Item = TokenTree>>(streams: I) -> Self
fn from_iter<I: IntoIterator<Item = TokenTree>>(streams: I) -> Self
sourceimpl 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.