# Crate proc_macro 1.15.0[−][src]

A support library for macro authors when defining new macros.

This library, provided by the standard distribution, provides the types consumed in the interfaces of procedurally defined macro definitions such as function-like macros `#[proc_macro]`, macro attribures `#[proc_macro_attribute]` and custom derive attributes`#[proc_macro_derive]`.

Note that this crate is intentionally bare-bones currently. This functionality is intended to be expanded over time as more surface area for macro authors is stabilized.

See the book for more.

## Modules

token_stream | [ Experimental ] Public implementation details for the `TokenStream` type, such as iterators.

## Macros

quote | [ Experimental ] `quote!(..)` accepts arbitrary tokens and expands into a `TokenStream` describing the input. For example, `quote!(a + b)` will produce a expression, that, when evaluated, constructs the `TokenStream` `[Ident("a"), Punct('+', Alone), Ident("b")]`.

## Structs

LexError | Error returned from `TokenStream::from_str`.
TokenStream | The main type provided by this crate, representing an abstract stream of tokens, or, more specifically, a sequence of token trees. The type provide interfaces for iterating over those token trees and, conversely, collecting a number of token trees into one stream.
Diagnostic | [ Experimental ] A structure representing a diagnostic message and associated children messages.
Group | [ Experimental ] A delimited token stream.
Ident | [ Experimental ] An identifier (`ident`).
LineColumn | [ Experimental ] A line-column pair representing the start or end of a `Span`.
Literal | [ Experimental ] A literal string (`"hello"`), byte string (`b"hello"`), character (`'a'`), byte character (`b'a'`), an integer or floating point number with or without a suffix (`1`, `1u8`, `2.3`, `2.3f32`). Boolean literals like `true` and `false` do not belong here, they are `Ident`s.
Punct | [ Experimental ] An `Punct` is an single punctuation character like `+`, `-` or `#`.
SourceFile | [ Experimental ] The source file of a given `Span`.
Span | [ Experimental ] A region of source code, along with macro expansion information.

## Enums

Delimiter | [ Experimental ] Describes how a sequence of token trees is delimited.
Level | [ Experimental ] An enum representing a diagnostic level.
Spacing | [ Experimental ] Whether an `Punct` is followed immediately by another `Punct` or followed by another token or whitespace.
TokenTree | [ Experimental ] A single token or a delimited sequence of token trees (e.g. `[1, (), ..]`).

## Functions

quote_span | [ Experimental ] Quote a `Span` into a `TokenStream`. This is needed to implement a custom quoter.

# 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`)

Search multiple things at once by splitting your query with comma (e.g. `str,u8` or `String,struct:Vec,test`)