Macro powerfmt::smart_display::padded_width_of

source ยท
macro_rules! padded_width_of {
    ($($t:tt)*) => { ... };
}
Expand description

Compute the width of multiple items while optionally declaring the options for each item.

let alpha = 0;
let beta = 1;
let gamma = 100;

let width = smart_display::padded_width_of!(
    alpha, // use the default options
    beta => width(2), // use the specified options
    gamma => width(2) sign_plus(true), // use multiple options
);
assert_eq!(width, 7);

let formatted = format!("{alpha}{beta:2}{gamma:+2}");
assert_eq!(formatted.len(), width);

Supported options are:

If there are future additions to FormatterOptions, they will be added to this macro as well.

Options may be provided in any order and will be called in the order they are provided. The ordering matters if providing both sign_plus and sign_minus.