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§
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§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: IntoIterator<Item = TokenStream>>(&mut self, streams: I)
fn extend<I: IntoIterator<Item = TokenStream>>(&mut self, streams: I)
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: IntoIterator<Item = TokenTree>>(&mut self, streams: I)
fn extend<I: IntoIterator<Item = TokenTree>>(&mut self, streams: I)
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) -> Self
fn from(inner: TokenStream) -> Self
Source§impl From<TokenStream> for TokenStream
impl From<TokenStream> for TokenStream
Source§fn from(inner: TokenStream) -> Self
fn from(inner: TokenStream) -> Self
Source§impl From<TokenTree> for TokenStream
impl From<TokenTree> for TokenStream
Source§impl FromIterator<TokenStream> for TokenStream
impl FromIterator<TokenStream> for TokenStream
Source§fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self
fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self
Source§impl FromIterator<TokenTree> for TokenStream
impl FromIterator<TokenTree> for TokenStream
Collects a number of token trees into a single stream.
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.