Struct pmutil::prelude::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]
impl TokenStream
pub fn new() -> TokenStream
[src]
pub fn new() -> TokenStream
Returns an empty TokenStream
containing no token trees.
pub fn empty() -> TokenStream
[src]
pub fn empty() -> TokenStream
: please use TokenStream::new
pub fn is_empty(&self) -> bool
[src]
pub fn is_empty(&self) -> bool
Checks if this TokenStream
is empty.
Trait Implementations
impl Extend<TokenTree> for TokenStream
[src]
impl Extend<TokenTree> for TokenStream
fn extend<I>(&mut self, streams: I) where
I: IntoIterator<Item = TokenTree>,
[src]
fn extend<I>(&mut self, streams: I) where
I: IntoIterator<Item = TokenTree>,
Extends a collection with the contents of an iterator. Read more
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>(streams: I) -> TokenStream where
I: IntoIterator<Item = TokenTree>,
[src]
fn from_iter<I>(streams: I) -> TokenStream where
I: IntoIterator<Item = TokenTree>,
Creates a value from an iterator. 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<(), Error>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. 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 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 Debug for TokenStream
[src]
impl Debug for TokenStream
Prints token in a form convenient for debugging.
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>
Formats the value using the given formatter. Read more
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 From<TokenStream> for TokenStream
[src]
impl From<TokenStream> for TokenStream
fn from(inner: TokenStream) -> TokenStream
[src]
fn from(inner: TokenStream) -> TokenStream
Performs the conversion.
impl From<TokenStream> for TokenStream
[src]
impl From<TokenStream> for TokenStream
fn from(inner: TokenStream) -> TokenStream
[src]
fn from(inner: TokenStream) -> TokenStream
Performs the conversion.
impl TokenStreamExt for TokenStream
[src]
impl TokenStreamExt for TokenStream
fn append<U>(&mut self, token: U) where
U: Into<TokenTree>,
[src]
fn append<U>(&mut self, token: U) where
U: Into<TokenTree>,
For use by ToTokens
implementations.
Appends the token specified to this list of tokens.
fn append_all<T, I>(&mut self, iter: I) where
I: IntoIterator<Item = T>,
T: ToTokens,
[src]
fn append_all<T, I>(&mut self, iter: I) where
I: IntoIterator<Item = T>,
T: ToTokens,
For use by ToTokens
implementations.
struct X; impl ToTokens for X { fn to_tokens(&self, tokens: &mut TokenStream) { tokens.append_all(&[true, false]); } } let tokens = quote!(#X); assert_eq!(tokens.to_string(), "true false");
fn append_separated<T, I, U>(&mut self, iter: I, op: U) where
I: IntoIterator<Item = T>,
T: ToTokens,
U: ToTokens,
[src]
fn append_separated<T, I, U>(&mut self, iter: I, op: U) where
I: IntoIterator<Item = T>,
T: ToTokens,
U: ToTokens,
For use by ToTokens
implementations.
Appends all of the items in the iterator I
, separated by the tokens
U
.
fn append_terminated<T, I, U>(&mut self, iter: I, term: U) where
I: IntoIterator<Item = T>,
T: ToTokens,
U: ToTokens,
[src]
fn append_terminated<T, I, U>(&mut self, iter: I, term: U) where
I: IntoIterator<Item = T>,
T: ToTokens,
U: ToTokens,
For use by ToTokens
implementations.
Appends all tokens in the iterator I
, appending U
after each
element, including after the last element of the iterator.
impl ToTokens for TokenStream
[src]
impl ToTokens for TokenStream
fn to_tokens(&self, dst: &mut TokenStream)
[src]
fn to_tokens(&self, dst: &mut TokenStream)
Write self
to the given TokenStream
. Read more
fn into_token_stream(self) -> TokenStream
[src]
fn into_token_stream(self) -> TokenStream
Convert self
directly into a TokenStream
object. Read more
impl Synom for TokenStream
[src]
impl Synom for TokenStream
fn parse(input: Cursor) -> Result<(TokenStream, Cursor), ParseError>
[src]
fn parse(input: Cursor) -> Result<(TokenStream, Cursor), ParseError>
fn description() -> Option<&'static str>
[src]
fn description() -> Option<&'static str>
A short name of the type being parsed. Read more
impl From<Quote> for TokenStream
[src]
impl From<Quote> for TokenStream
Auto Trait Implementations
impl !Send for TokenStream
impl !Send for TokenStream
impl !Sync for TokenStream
impl !Sync for TokenStream