Macro format_args

Source
macro_rules! format_args {
    ($fmt:literal $(, $($arg:tt)*)?) => { ... };
    ($fmt:expr $(, $($arg:tt)*)?) => { ... };
}
Available on crate feature macros only.
Expand description

Constructs parameters for the other string-formatting macros.

This macro functions by taking a formatting string literal containing {} for each additional argument passed. format_args! prepares the additional parameters to ensure the output can be interpreted as a string and canonicalizes the arguments into a single type. Any value that implements the stylish::Display trait or any of the std::fmt formatting traits can be passed to format_args! with the appropriate trait selector.

This macro produces a value of type stylish::Arguments. This value can be passed to the macros within stylish for performing useful redirection. All other formatting macros (stylish::format!, stylish::write!, etc) are proxied through this one. format_args!, unlike some of its derived macros, avoids heap allocations.

For more information, see the documentation in stylish.

ยงExamples

let s = stylish::html::format(stylish::format_args!(
    "hello {:(fg=green)}",
    "world"
));
assert_eq!(s, stylish::html::format!("hello {:(fg=green)}", "world"));