Macro write

Source
macro_rules! write {
    ($dst:expr, $($arg:tt)*) => { ... };
}
Expand description

Writes attributed and formatted data into a buffer.

This macro accepts a ‘writer’, a format string, and a list of arguments. Arguments will be formatted according to the specified format string and the result will be passed to the writer. The writer may be any value with a write_fmt method of the right signature; generally this comes from an implementation of either the stylish::Write or the stylish::io::Write trait. The macro returns whatever the write_fmt method returns; commonly a core::fmt::Result, or a std::io::Result.

See stylish for more information on the format string syntax.

§Examples

let mut w = stylish::html(String::new());

stylish::write!(&mut w, "test")?;
stylish::write!(&mut w, "formatted {:(fg=yellow)}", "arguments")?;

assert_eq!(
    w.finish()?,
    "testformatted <span style=color:yellow>arguments</span>"
);