Expand description
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.
Re-exportsยง
pub(crate) use core::convert::From;๐pub(crate) use core::ops::BitOr;๐pub(crate) use std::borrow::Cow;๐pub(crate) use std::ffi::CStr;๐pub(crate) use Range;๐pub(crate) use RangeBounds;๐pub(crate) use std::path::PathBuf;๐pub(crate) use std::str::FromStr;๐pub(crate) use error;๐pub(crate) use fmt;๐pub(crate) use MixedUnit;๐pub(crate) use unescape_byte;๐pub(crate) use unescape_byte_str;๐pub(crate) use unescape_c_str;๐pub(crate) use unescape_char;๐pub(crate) use unescape_str;๐pub use quote::quote;Experimental pub use quote::quote_span;Experimental
Modulesยง
- diagnostic ๐
- escape ๐
- to_
tokens ๐ - token_
stream - Public implementation details for the
TokenStreamtype, such as iterators. - tracked
Experimental - Functionality for adding environment state to the build dependency info.
Macrosยง
- diagnostic_
method ๐ - extend_
items ๐ - float_
values ๐ - integer_
values ๐ - suffixed_
int_ ๐literals - unsuffixed_
int_ ๐literals - quote
Experimental quote!(..)accepts arbitrary tokens and expands into aTokenStreamdescribing the input. For example,quote!(a + b)will produce an expression, that, when evaluated, constructs theTokenStream[Ident("a"), Punct('+', Alone), Ident("b")].
Structsยง
- Concat
Streams ๐Helper - Non-generic helper for implementing
FromIterator<TokenStream>andExtend<TokenStream>with less monomorphization in calling crates. - Concat
Trees ๐Helper - Non-generic helper for implementing
FromIterator<TokenTree>andExtend<TokenTree>with less monomorphization in calling crates. - Escape
Options ๐ - 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"), C string (c"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 liketrueandfalsedo not belong here, they areIdents. - Punct
- A
Punctis a single punctuation character such as+,-or#. - Span
- A region of source code, along with macro expansion information.
- Token
Stream - The main type provided by this crate, representing an abstract stream of tokens, or, more specifically, a sequence of token trees. The type provides interfaces for iterating over those token trees and, conversely, collecting a number of token trees into one stream.
- Bridge
Methods ๐Experimental - Diagnostic
Experimental - A structure representing a diagnostic message and associated children messages.
- Expand
Error Experimental - Error returned from
TokenStream::expand_expr.
Enumsยง
- Base ๐
- Delimiter
- Describes how a sequence of token trees is delimited.
- Spacing
- Indicates whether a
Puncttoken can join with the following token to form a multi-character operator. - Token
Tree - A single token or a delimited sequence of token trees (e.g.,
[1, (), ..]). - Conversion
Error Kind Experimental - Errors returned when trying to retrieve a literal unescaped value.
- Escape
Error Experimental - Mostly relating to malformed escape sequences, but also a few other problems.
- Level
Experimental - An enum representing a diagnostic level.
Traitsยง
- Multi
Span Experimental - Trait implemented by types that can be converted into a set of
Spans. - ToTokens
Experimental - Types that can be interpolated inside a
quote!invocation.
Functionsยง
- escape_
bytes ๐ - is_
available - Determines whether proc_macro has been made accessible to the currently running program.
- parse_
number ๐ - strip_
underscores ๐ - tree_
to_ ๐bridge_ tree - quote
Experimental - Quote a
TokenStreaminto aTokenStream. This is the actual implementation of thequote!()proc macro. - quote_
span Experimental - Quote a
Spaninto aTokenStream. This is needed to implement a custom quoter.