Module macros

Source
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:

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§

CoreFmtFormatStringParser
An implementation of FormatStringParser that parsers core::fmt style format strings.
Error
An error occurring during proc macro evaluation.
FormatAndArgs
A parsed format string and it’s arguments.
FormatAndArgsFlavor
A variant of FormatAndArgs that is generic over format string flavor.
FormatParams
Formatting parameters passed to an untyped conversion.
PrintfFormatStringParser
An implementation of FormatStringParser that parsers printf style format strings.

Enums§

Arg
An argument to a pw_format backed macro.
PrintfFormatStringFragment
A fragment of a printf format string.

Traits§

CoreFmtFormatMacroGenerator
A specialized generator for proc macros that produce core::fmt style format strings.
FormatMacroGenerator
A code generator for implementing a pw_format style macro.
FormatStringParser
A trait for parsing a string into a FormatString.
PrintfFormatMacroGenerator
A specialized generator for proc macros that produce printf style format strings.

Functions§

generate
Generate code for a pw_format style proc macro.
generate_core_fmt
Generate code for a pw_format style proc macro that needs a core::fmt format string.
generate_printf
Generate code for a pw_format style proc macro that needs a printf format string.

Type Aliases§

Result
An alias for a Result with an Error