Struct proc_macro2::TokenStream
[−]
[src]
pub struct TokenStream { /* fields omitted */ }
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.
Methods
impl TokenStream
[src]
pub fn new() -> TokenStream
[src]
Returns an empty TokenStream
containing no token trees.
pub fn empty() -> TokenStream
[src]
: please use TokenStream::new
pub fn is_empty(&self) -> bool
[src]
Checks if this TokenStream
is empty.
Trait Implementations
impl IntoIterator for TokenStream
[src]
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]
Creates an iterator from a value. Read more
impl Clone for TokenStream
[src]
fn clone(&self) -> TokenStream
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Default for TokenStream
[src]
TokenStream::default()
returns an empty stream,
i.e. this is equivalent with TokenStream::new()
.
impl FromStr for TokenStream
[src]
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]
Parses a string s
to return a value of this type. Read more
impl From<TokenStream> for TokenStream
[src]
fn from(inner: TokenStream) -> TokenStream
[src]
Performs the conversion.
impl From<TokenStream> for TokenStream
[src]
fn from(inner: TokenStream) -> TokenStream
[src]
Performs the conversion.
impl Extend<TokenTree> for TokenStream
[src]
fn extend<I: IntoIterator<Item = TokenTree>>(&mut self, streams: I)
[src]
Extends a collection with the contents of an iterator. Read more
impl Extend<TokenStream> for TokenStream
[src]
fn extend<I: IntoIterator<Item = TokenStream>>(&mut self, streams: I)
[src]
Extends a collection with the contents of an iterator. Read more
impl FromIterator<TokenTree> for TokenStream
[src]
Collects a number of token trees into a single stream.
fn from_iter<I: IntoIterator<Item = TokenTree>>(streams: I) -> Self
[src]
Creates a value from an iterator. Read more
impl Display for TokenStream
[src]
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]
Formats the value using the given formatter. Read more
impl Debug for TokenStream
[src]
Prints token in a form convenient for debugging.