pub trait CoreFmtFormatMacroGenerator {
// Required methods
fn finalize(self, format_string: String) -> Result<TokenStream>;
fn string_fragment(&mut self, string: &str) -> Result<()>;
fn integer_conversion(
&mut self,
ty: Ident,
expression: Arg,
) -> Result<Option<String>>;
fn string_conversion(&mut self, expression: Arg) -> Result<Option<String>>;
fn char_conversion(&mut self, expression: Arg) -> Result<Option<String>>;
// Provided method
fn untyped_conversion(&mut self, _expression: Arg) -> Result<()> { ... }
}Expand description
A specialized generator for proc macros that produce core::fmt style format strings.
For proc macros that need to translate a pw_format invocation into a
core::fmt style format string, CoreFmtFormatMacroGenerator offer a
specialized form of FormatMacroGenerator that builds the format string
and provides it as an argument to
finalize.
In cases where a generator needs to override the conversion specifier (i.e.
{}, it can return it from its appropriate conversion method.
Required Methods§
Sourcefn finalize(self, format_string: String) -> Result<TokenStream>
fn finalize(self, format_string: String) -> Result<TokenStream>
Called by generate_core_fmt at the end of code generation.
Works like FormatMacroGenerator::finalize with the addition of
being provided a core::fmt format string.
Sourcefn string_fragment(&mut self, string: &str) -> Result<()>
fn string_fragment(&mut self, string: &str) -> Result<()>
Process a string fragment.
NOTE: This string may contain unescaped { and } characters.
However, most implementations of this train can simply ignore string
fragments as they will be included (with properly escaped { and }
characters) as part of the format string passed to
CoreFmtFormatMacroGenerator::finalize.
See FormatMacroGenerator::string_fragment for a disambiguation
between a string fragment and string conversion.
Sourcefn integer_conversion(
&mut self,
ty: Ident,
expression: Arg,
) -> Result<Option<String>>
fn integer_conversion( &mut self, ty: Ident, expression: Arg, ) -> Result<Option<String>>
Process an integer conversion.
Provided Methods§
Sourcefn untyped_conversion(&mut self, _expression: Arg) -> Result<()>
fn untyped_conversion(&mut self, _expression: Arg) -> Result<()>
Process an untyped conversion.