proc_macro::TokenStream - Rust
Description: API documentation for the Rust `TokenStream` struct in crate `proc_macro`.
Keywords: rust, rustlang, rust-lang, TokenStream

# Struct proc_macro::TokenStream 1.15.0 [−] [src]

    pub struct TokenStream(_);

The main type provided by this crate, representing an abstract stream of tokens.

This is both the input and output of `#[proc_macro_derive]` definitions. Currently it's required to be a list of valid Rust items, but this restriction may be lifted in the future.

The API of this type is intentionally bare-bones, but it'll be expanded over time!

## Methods

### `impl TokenStream`
[src]

#### `pub fn empty() -> TokenStream`
[src]

🔬 This is a nightly-only experimental API. (`proc_macro` #38356)

Returns an empty `TokenStream`.

#### `pub fn is_empty(&self) -> bool`
[src]

🔬 This is a nightly-only experimental API. (`proc_macro` #38356)

Checks if this `TokenStream` is empty.

## Trait Implementations

### `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 Debug for TokenStream`
[src]

#### `fn fmt(&self, __arg_0: &mut Formatter) -> Result`
[src]

Formats the value using the given formatter. Read more

### `impl FromStr for TokenStream`
[src]

#### `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 Display for TokenStream`
[src]

#### `fn fmt(&self, f: &mut Formatter) -> Result`
[src]

Formats the value using the given formatter. Read more

### `impl From<TokenTree> for TokenStream`
[src]

#### `fn from(tree: TokenTree) -> TokenStream`
[src]

Performs the conversion.

### `impl From<TokenNode> for TokenStream`
[src]

#### `fn from(kind: TokenNode) -> TokenStream`
[src]

Performs the conversion.

### `impl<T: Into<TokenStream>> FromIterator<T> for TokenStream`
[src]

#### `fn from_iter<I: IntoIterator<Item = T>>(streams: I) -> Self`
[src]

Creates a value from an iterator. Read more

### `impl IntoIterator for TokenStream`
[src]

#### `type Item = TokenTree`

The type of the elements being iterated over.

#### `type IntoIter = TokenTreeIter`

Which kind of iterator are we turning this into?

####
ⓘImportant traits for TokenTreeIter

### Important traits for TokenTreeIter

`impl Iterator for TokenTreeIter type Item = TokenTree;`
`fn into_iter(self) -> TokenTreeIter`
[src]

Creates an iterator from a value. Read more

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
↑
  Move up in search results
↓
  Move down in search results
↹
  Switch tab
⏎
  Go to active search result
+ / -
  Collapse/expand all sections

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize` or `* -> vec`)