Crate proc_macro1.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. Currently the primary use of this crate is to provide the ability to define new custom derive modes through #[proc_macro_derive].

Note that this crate is intentionally very bare-bones currently. The main type, TokenStream, only supports fmt::Display and FromStr implementations, indicating that it can only go to and come from a string. This functionality is intended to be expanded over time as more surface area for macro authors is stabilized.

See the book for more.

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 constructs the TokenStream [Word("a"), Op('+', Alone), Word("b")].

Structs

LexError

Error returned from TokenStream::from_str.

TokenStream

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

Literal [
Experimental
]

A literal character ('a'), string ("hello"), or number (2.3).

Span [
Experimental
]

A region of source code, along with macro expansion information.

Term [
Experimental
]

An interned string.

TokenTree [
Experimental
]

A single token or a delimited sequence of token trees (e.g. [1, (), ..]).

TokenTreeIter [
Experimental
]

An iterator over TokenTrees.

Enums

Delimiter [
Experimental
]

Describes how a sequence of token trees is delimited.

Spacing [
Experimental
]

Whether an Op is either followed immediately by another Op or followed by whitespace.

TokenNode [
Experimental
]

Description of a TokenTree

Functions

quote_span [
Experimental
]

Quote a Span into a TokenStream. This is needed to implement a custom quoter.