macro_rules! dformat {
($template:literal, $($args:tt)*) => { ... };
($template:expr, $($args:tt)*) => { ... };
}Expand description
Dynamic drop in format! replacement.
use dfmt::*;
let template = "This example template {contains:*^width$} multiple {{{0}}}
named and {} indexed args {0:+020o} {3:#?} {:.*}.";
let precompiled_template = Template::parse(template).unwrap();
dformat!(template, contains = "STH", 42, 3, 3.1423223, template, width=50).unwrap();
dformat!(precompiled_template, contains = "STH", 42, 3, 3.1423223, template, width=50).unwrap();
// Use `format!` under the hood
dformat!("Hello, {}!", "World").unwrap();ยงSupported features
| Name | Feature |
|---|---|
| Fill/Alignment | <, ^, > |
| Sign | +, - |
| Alternate | # |
| Zero-padding | 0 |
| Width | {:20}, {:width$} |
| Precision | {:.5}, {:.precision$}, {:*} |
| Type | ?, x, X, o, b, e, E, p |
| Argument keys | {}, {0}, {arg} |