Expand description
The macro
module provides helpers that simplify writing proc macros
that take format strings and arguments. This is accomplish with three
main constructs:
FormatAndArgsFlavor
: A struct that implements syn::parse::Parse to parse a format string and its following arguments.FormatMacroGenerator
: A trait used to implement the macro specific logic to generate code.generate
: A function to handle the execution of the proc macro by calling into a FormatMacroGenerator.
Additionally PrintfFormatMacroGenerator
trait and generate_printf
function are provided to help when implementing generators that need to
produce printf
style format strings as part of their code generation.
§Example
An example of implementing a proc macro is provided in the pw_format_example_macro crate
Structs§
- An implementation of
FormatStringParser
that parserscore::fmt
style format strings. - An error occurring during proc macro evaluation.
- A parsed format string and it’s arguments.
- A variant of
FormatAndArgs
that is generic over format string flavor. - Formatting parameters passed to an untyped conversion.
- An implementation of
FormatStringParser
that parsersprintf
style format strings.
Enums§
- An argument to a
pw_format
backed macro. - A fragment of a printf format string.
Traits§
- A specialized generator for proc macros that produce
core::fmt
style format strings. - A code generator for implementing a
pw_format
style macro. - A trait for parsing a string into a
FormatString
. - A specialized generator for proc macros that produce
printf
style format strings.
Functions§
- Generate code for a
pw_format
style proc macro. - Generate code for a
pw_format
style proc macro that needs acore::fmt
format string. - Generate code for a
pw_format
style proc macro that needs aprintf
format string.
Type Aliases§
- An alias for a Result with an
Error