Expand description
Batteries-included proc-macro utils
This re-exports the common libraries - syn, quote, and proc-macro2,
that you need to work with proc-macros, as well as utilities
to interop between them.
§Re-exports
Most of quote, proc_macro, and proc_macro2 are re-exported,
and they can be used with the pm:: prefix. Types that have the same
name in proc_macro and proc_macro2 are suffixed with 2 in
the proc_macro2 export.
Types from syn can be used as with syn:: prefix, by adding
the prelude import use pm::pre::*.
Modules§
Macros§
- bail
- Bail with a
syn::Error. Use from a function that returnssyn::Result. - format_
ident - Formatting macro for constructing
Idents. - quote
- The whole point.
- quote_
spanned - Same as
quote!, but applies a given span to all tokens originating within the macro invocation.
Structs§
- Error
- Error returned when a Syn parser cannot parse the input tokens.
- Group
- A delimited token stream.
- Group2
- A delimited token stream.
- Ident
- An identifier (
ident). - Ident2
- A word of Rust code, which may be a keyword or legal variable name.
- LexError
- Error returned from
TokenStream::from_str. - LexError2
- 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. - Literal2
- 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). - Punct
- A
Punctis a single punctuation character such as+,-or#. - Punct2
- A
Punctis a single punctuation character like+,-or#. - Span
- A region of source code, along with macro expansion information.
- Span2
- 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.
- Token
Stream2 - An abstract stream of tokens, or more concretely a sequence of token trees.
Enums§
- Delimiter
- Describes how a sequence of token trees is delimited.
- Delimiter2
- 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. - Spacing2
- Whether a
Punctis followed immediately by anotherPunctor followed by another token or whitespace. - Token
Tree - A single token or a delimited sequence of token trees (e.g.,
[1, (), ..]). - Token
Tree2 - A single token or a delimited sequence of token trees (e.g.
[1, (), ..]).
Traits§
- ToTokens
- Types that can be interpolated inside a
quote!invocation.
Functions§
- flatten
- Flatten an expansion result or error into token stream.
- parse_
punctuated - Convenience wrapper for parsing punctuated syntax
- parse_
punctuated2 - Convenience wrapper for parsing punctuated syntax
Type Aliases§
- Result
- The result of a Syn parser.