[−][src]Crate runtime_fmt
A crate for string formatting using runtime format strings.
This crate provides much the same facilities as std::fmt
, with the
additional allowance for format strings which are not known until runtime.
Possible applications include internationalization, scripting, or other
customization.
Each of the standard formatting macros format_args!
, format!
,
print!
, println!
, write!
, and writeln!
have corresponding rt_
variants. Calls which previously succeeded unconditionally now return
Result
, which may indicate a bad format string or arguments.
The syntax for format strings and for macro invocations is equivalent to
that used by std::fmt
, including support for positional and named
arguments. This crate shells out to the standard library implementations
for as much as possible to ensure feature parity.
Macros
rt_format | Format a value of type |
rt_format_args | The core macro for runtime formatting. |
rt_print | Print to standard output with a runtime format string. |
rt_println | Print to standard output with a runtime format string and trailing newline. |
rt_write | Write runtime-formatted data into a buffer. |
rt_writeln | Write runtime-formatted data into a buffer with a trailing newline. |
Structs
FormatBuf | A buffer representing a parsed format string and arguments. |
Param | A type-erased parameter, with an optional name. |
PreparedFormat | A pre-checked format string, ready for values of a specific type to be formatted against it. |
Enums
Error | An error during parsing or formatting. |
Traits
FormatArgs | A trait for types against which formatting specifiers may be pre-checked. |