Macro table_formatter::fmt

source ·
macro_rules! fmt {
    () => { ... };
    ($func: expr) => { ... };
    ($($func: expr),+ $(,)?) => { ... };
}
Expand description

This macro is used to wrap those formatters.

Since the formatters use both closures and functions, and that two types are not capable with each other, the lib uses a enum(FormatterFunc) to combine them together.

This macro will automatically convert any function pointers and closures to a Rc<Box<dyn Fn(...) -> ...>>, generating FormatterFunc::Boxed.

You can just use it as the way you use the vec! macro.

let (r, g, b) = (100, 20, 70);
fmt!(Colorize::blue, move |s| s.truecolor(r, g, b));