Crate custom_format
source · [−]Expand description
This crate extends the standard formatting syntax with custom format specifiers, by providing custom formatting macros.
It uses :
(a space and a colon) as a separator before the format specifier, which is not a syntax currently accepted and allows supporting standard specifiers in addition to custom specifiers.
It also supports format args capture
even on older versions of Rust, since it manually adds the named parameter if missing.
This library comes in two flavors, corresponding to the following features:
-
compile-time
(enabled by default)The set of possible custom format specifiers is defined at compilation, so invalid specifiers can be checked at compile-time. This allows the library to have the same performance as when using the standard library formatting traits. See the
compile_time::CustomFormat
trait. -
runtime
(enabled by default)The formatting method dynamically checks the format specifier at runtime for each invocation. This is a slower version, but has a lower MSRV for greater compatibility. See the
runtime::CustomFormat
trait.
Modules
compile-time
Provides types associated to compile-time formatting.
runtime
Provides types associated to runtime formatting.
Macros
Helper macro for constructing a new compile_time::CustomFormatter
value from a format specifier
Prints to the standard error
Prints to the standard error, with a newline
Creates a String
using interpolation of runtime expressions
Constructs parameters for the other string-formatting macros.
Panics the current thread
Prints to the standard output
Prints to the standard output, with a newline
Writes formatted data into a buffer
Write formatted data into a buffer, with a newline appended