macro_rules! write {
($dst:expr, [$($arg:expr),+ $(,)?]) => { ... };
}Expand description
Writes formatted data into a buffer.
This macro accepts a ‘buffer’ and a list of format arguments. Each argument will be formatted
and the result will be passed to the buffer. The writer may be any value with a write_fmt method;
generally this comes from an implementation of the crate::Buffer trait.
§Examples
use ruff_formatter::prelude::*;
use ruff_formatter::{Buffer, FormatState, SimpleFormatContext, VecBuffer, write};
let mut state = FormatState::new(SimpleFormatContext::default());
let mut buffer = VecBuffer::new(&mut state);
write!(&mut buffer, [token("Hello"), space()])?;
write!(&mut buffer, [token("World")])?;
assert_eq!(
buffer.into_vec(),
vec![
FormatElement::Token { text: "Hello" },
FormatElement::Space,
FormatElement::Token { text: "World" },
]
);