Function stylish_core::format
source · pub fn format(args: Arguments<'_>) -> StringAvailable on crate feature
alloc only.Expand description
The format function takes a stylish::Arguments struct and returns the
resulting attributed and formatted stylish::String.
The stylish::Arguments instance can be created with the
stylish::format_args! macro.
§Examples
Basic usage:
let s = stylish::format(stylish::format_args!(
"Hello, {:(fg=green)}!",
"world"
));
assert_eq!(
stylish::html::format!("{:s}", s),
"Hello, <span style=color:green>world</span>!"
);Please note that using stylish::format! might be preferable. Example:
let s = stylish::format!("Hello, {:(fg=green)}!", "world");
assert_eq!(
stylish::html::format!("{:s}", s),
"Hello, <span style=color:green>world</span>!"
);