# Trait quote::ToTokens [−] [src]

    pub trait ToTokens {
        fn to_tokens(&self, _: &mut Tokens);
    }

Types that can be interpolated inside a `quote!(...)` invocation.

## Required Methods

### `fn to_tokens(&self, _: &mut Tokens)`

Write `self` to the given `Tokens`.

Example implementation for a struct representing Rust paths like `std::cmp::PartialEq`:

ⓘThis example is not tested

    pub struct Path {
        pub global: bool,
        pub segments: Vec<PathSegment>,
    }

    impl ToTokens for Path {
        fn to_tokens(&self, tokens: &mut Tokens) {
            for (i, segment) in self.segments.iter().enumerate() {
                if i > 0 || self.global {
                    tokens.append("::");
                }
                segment.to_tokens(tokens);
            }
        }
    }

## Implementations on Foreign Types

### `impl<'a, T: ?Sized + ToTokens> ToTokens for &'a T`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<'a, T: ?Sized + ToOwned + ToTokens> ToTokens for Cow<'a, T>`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ?Sized + ToTokens> ToTokens for Box<T>`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for Option<T>`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl ToTokens for str`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl ToTokens for String`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl ToTokens for char`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl ToTokens for bool`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl ToTokens for i8`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl ToTokens for i16`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl ToTokens for i32`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl ToTokens for i64`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl ToTokens for isize`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl ToTokens for u8`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl ToTokens for u16`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl ToTokens for u32`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl ToTokens for u64`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl ToTokens for usize`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl ToTokens for f32`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl ToTokens for f64`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for Vec<T>`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 0]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 1]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 2]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 3]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 4]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 5]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 6]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 7]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 8]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 9]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 10]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 11]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 12]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 13]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 14]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 15]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 16]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 17]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 18]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 19]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 20]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 21]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 22]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 23]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 24]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 25]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 26]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 27]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 28]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 29]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 30]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 31]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<T: ToTokens> ToTokens for [T; 32]`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl ToTokens for ()`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<A: ToTokens> ToTokens for (A,)`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<A: ToTokens, B: ToTokens> ToTokens for (A, B)`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<A: ToTokens, B: ToTokens, C: ToTokens> ToTokens for (A, B, C)`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<A: ToTokens, B: ToTokens, C: ToTokens, D: ToTokens> ToTokens for (A, B, C, D)`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<A: ToTokens, B: ToTokens, C: ToTokens, D: ToTokens, E: ToTokens> ToTokens for (A, B, C, D, E)`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<A: ToTokens, B: ToTokens, C: ToTokens, D: ToTokens, E: ToTokens, F: ToTokens> ToTokens for (A, B, C, D, E, F)`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<A: ToTokens, B: ToTokens, C: ToTokens, D: ToTokens, E: ToTokens, F: ToTokens, G: ToTokens> ToTokens for (A, B, C, D, E, F, G)`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<A: ToTokens, B: ToTokens, C: ToTokens, D: ToTokens, E: ToTokens, F: ToTokens, G: ToTokens, H: ToTokens> ToTokens for (A, B, C, D, E, F, G, H)`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<A: ToTokens, B: ToTokens, C: ToTokens, D: ToTokens, E: ToTokens, F: ToTokens, G: ToTokens, H: ToTokens, I: ToTokens> ToTokens for (A, B, C, D, E, F, G, H, I)`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<A: ToTokens, B: ToTokens, C: ToTokens, D: ToTokens, E: ToTokens, F: ToTokens, G: ToTokens, H: ToTokens, I: ToTokens, J: ToTokens> ToTokens for (A, B, C, D, E, F, G, H, I, J)`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<A: ToTokens, B: ToTokens, C: ToTokens, D: ToTokens, E: ToTokens, F: ToTokens, G: ToTokens, H: ToTokens, I: ToTokens, J: ToTokens, K: ToTokens> ToTokens for (A, B, C, D, E, F, G, H, I, J, K)`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

### `impl<A: ToTokens, B: ToTokens, C: ToTokens, D: ToTokens, E: ToTokens, F: ToTokens, G: ToTokens, H: ToTokens, I: ToTokens, J: ToTokens, K: ToTokens, L: ToTokens> ToTokens for (A, B, C, D, E, F, G, H, I, J, K, L)`
[src]

#### `fn to_tokens(&self, tokens: &mut Tokens)`
[src]

## Implementors

- [src]
  `impl<'a> ToTokens for ByteStr<'a>`
- [src]
  `impl ToTokens for Tokens`
- [src]
  `impl ToTokens for Hex<i8>`
- [src]
  `impl ToTokens for Hex<i16>`
- [src]
  `impl ToTokens for Hex<i32>`
- [src]
  `impl ToTokens for Hex<i64>`
- [src]
  `impl ToTokens for Hex<isize>`
- [src]
  `impl ToTokens for Hex<u8>`
- [src]
  `impl ToTokens for Hex<u16>`
- [src]
  `impl ToTokens for Hex<u32>`
- [src]
  `impl ToTokens for Hex<u64>`
- [src]
  `impl ToTokens for Hex<usize>`
- [src]
  `impl ToTokens for Ident`

# 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
`+`
  Expand all sections
`-`
  Collapse 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`)