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_timecompile-time
Provides types associated to compile-time formatting.
runtimeruntime
Provides types associated to runtime formatting.

Macros§

custom_formattercompile-time
Helper macro for constructing a new compile_time::CustomFormatter value from a format specifier
eprint
Prints to the standard error
eprintln
Prints to the standard error, with a newline
format
Creates a String using interpolation of runtime expressions
format_args
Constructs parameters for the other string-formatting macros.
panic
Panics the current thread
print
Prints to the standard output
println
Prints to the standard output, with a newline
write
Writes formatted data into a buffer
writeln
Write formatted data into a buffer, with a newline appended