Struct proc_macro::TokenStream 1.15.0[−][src]
pub struct TokenStream(_);
The main type provided by this crate, representing an abstract stream of tokens, or, more specifically, a sequence of token trees. The type provide interfaces for iterating over those token trees and, conversely, collecting a number of token trees into one stream.
This is both the input and output of #[proc_macro]
, #[proc_macro_attribute]
and #[proc_macro_derive]
definitions.
The API of this type is intentionally bare-bones, but it'll be expanded over time!
Methods
impl TokenStream
[src]
impl TokenStream
pub fn empty() -> TokenStream
[src]
pub fn empty() -> TokenStream
Returns an empty TokenStream
containing no token trees.
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Checks if this TokenStream
is empty.
Trait Implementations
impl IntoIterator for TokenStream
[src]
impl IntoIterator for TokenStream
type Item = TokenTree
The type of the elements being iterated over.
type IntoIter = IntoIter
Which kind of iterator are we turning this into?
ⓘImportant traits for IntoIterfn into_iter(self) -> IntoIter
[src]
fn into_iter(self) -> IntoIter
Creates an iterator from a value. Read more
impl Clone for TokenStream
[src]
impl Clone for TokenStream
fn clone(&self) -> TokenStream
[src]
fn clone(&self) -> TokenStream
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
impl !Send for TokenStream
[src]
impl !Send for TokenStream
impl !Sync for TokenStream
[src]
impl !Sync for TokenStream
impl FromStr for TokenStream
[src]
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.
type Err = LexError
The associated error which can be returned from parsing.
fn from_str(src: &str) -> Result<TokenStream, LexError>
[src]
fn from_str(src: &str) -> Result<TokenStream, LexError>
Parses a string s
to return a value of this type. Read more
impl Display for TokenStream
[src]
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.
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl Debug for TokenStream
[src]
impl Debug for TokenStream
Prints token in a form convenient for debugging.
fn fmt(&self, f: &mut Formatter) -> Result
[src]
fn fmt(&self, f: &mut Formatter) -> Result
Formats the value using the given formatter. Read more
impl From<TokenTree> for TokenStream
[src]
impl From<TokenTree> for TokenStream
Creates a token stream containing a single token tree.
fn from(tree: TokenTree) -> TokenStream
[src]
fn from(tree: TokenTree) -> TokenStream
Performs the conversion.
impl FromIterator<TokenTree> for TokenStream
[src]
impl FromIterator<TokenTree> for TokenStream
Collects a number of token trees into a single stream.
fn from_iter<I: IntoIterator<Item = TokenTree>>(trees: I) -> Self
[src]
fn from_iter<I: IntoIterator<Item = TokenTree>>(trees: I) -> Self
Creates a value from an iterator. Read more
impl FromIterator<TokenStream> for TokenStream
[src]
impl FromIterator<TokenStream> for TokenStream
A "flattening" operation on token streams, collects token trees from multiple token streams into a single stream.
fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self
[src]
fn from_iter<I: IntoIterator<Item = TokenStream>>(streams: I) -> Self
Creates a value from an iterator. Read more