1.15.0[][src]Crate proc_macro

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 attributes #[proc_macro_attribute] and custom derive attributes#[proc_macro_derive].

See the book for more.

Modules

token_stream

Public implementation details for the TokenStream type, such as iterators.

Macros

quoteExperimental

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

Group

A delimited token stream.

Ident

An identifier (ident).

LexError

Error returned from TokenStream::from_str.

Literal

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 Idents.

Punct

An Punct is an single punctuation character like +, - or #.

Span

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

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.

DiagnosticExperimental

A structure representing a diagnostic message and associated children messages.

LineColumnExperimental

A line-column pair representing the start or end of a Span.

SourceFileExperimental

The source file of a given Span.

Enums

Delimiter

Describes how a sequence of token trees is delimited.

Spacing

Whether an Punct is followed immediately by another Punct or followed by another token or whitespace.

TokenTree

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

LevelExperimental

An enum representing a diagnostic level.

Traits

MultiSpanExperimental

Trait implemented by types that can be converted into a set of Spans.

Functions

quoteExperimental

Quote a TokenStream into a TokenStream. This is the actual quote!() proc macro.

quote_spanExperimental

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