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]

Returns an empty TokenStream containing no token trees.

Deprecated since 0.4.4

: please use TokenStream::new

Checks if this TokenStream is empty.

Trait Implementations

impl Extend<TokenTree> for TokenStream
[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.

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::Groups with Delimiter::None delimiters and negative numeric literals.

Formats the value using the given formatter. Read more

impl Clone for TokenStream
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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 LexErrors later.

The associated error which can be returned from parsing.

Parses a string s to return a value of this type. Read more

impl Debug for TokenStream
[src]

Prints token in a form convenient for debugging.

Formats the value using the given formatter. Read more

impl IntoIterator for TokenStream
[src]

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Important traits for IntoIter

Creates an iterator from a value. Read more

impl From<TokenStream> for TokenStream
[src]

Performs the conversion.

impl From<TokenStream> for TokenStream
[src]

Performs the conversion.

impl TokenStreamExt for TokenStream
[src]

For use by ToTokens implementations.

Appends the token specified to this list of tokens.

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");

For use by ToTokens implementations.

Appends all of the items in the iterator I, separated by the tokens U.

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]

Write self to the given TokenStream. Read more

Convert self directly into a TokenStream object. Read more

impl Synom for TokenStream
[src]

A short name of the type being parsed. Read more

impl From<Quote> for TokenStream
[src]

Performs the conversion.

Auto Trait Implementations

impl !Send for TokenStream

impl !Sync for TokenStream