Macro biome_formatter::prelude::write
source · 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 biome_formatter::prelude::*;
use biome_formatter::{Buffer, FormatState, SimpleFormatContext, VecBuffer, write};
let mut state = FormatState::new(SimpleFormatContext::default());
let mut buffer = VecBuffer::new(&mut state);
write!(&mut buffer, [text("Hello"), space()])?;
write!(&mut buffer, [text("World")])?;
assert_eq!(
buffer.into_vec(),
vec![
FormatElement::StaticText { text: "Hello" },
FormatElement::Space,
FormatElement::StaticText { text: "World" },
]
);