Struct biome_formatter::RemoveSoftLinesBuffer
source · pub struct RemoveSoftLinesBuffer<'a, Context> { /* private fields */ }
Expand description
A Buffer that removes any soft line breaks.
§Examples
use biome_formatter::prelude::*;
use biome_formatter::{format, write};
use biome_formatter::{RemoveSoftLinesBuffer, SimpleFormatContext, VecBuffer};
use biome_formatter::prelude::format_with;
let formatted = format!(
SimpleFormatContext::default(),
[format_with(|f| {
let mut buffer = RemoveSoftLinesBuffer::new(f);
write!(
buffer,
[
text("The next soft line or space gets replaced by a space"),
soft_line_break_or_space(),
text("and the line here"),
soft_line_break(),
text("is removed entirely.")
]
)
})]
)?;
assert_eq!(
formatted.document().as_ref(),
&[
FormatElement::StaticText { text: "The next soft line or space gets replaced by a space" },
FormatElement::Space,
FormatElement::StaticText { text: "and the line here" },
FormatElement::StaticText { text: "is removed entirely." }
]
);
Implementations§
Trait Implementations§
source§impl<Context> Buffer for RemoveSoftLinesBuffer<'_, Context>
impl<Context> Buffer for RemoveSoftLinesBuffer<'_, Context>
source§fn write_element(&mut self, element: FormatElement) -> FormatResult<()>
fn write_element(&mut self, element: FormatElement) -> FormatResult<()>
Writes a crate::FormatElement into this buffer, returning whether the write succeeded. Read more
source§fn state(&self) -> &FormatState<Self::Context>
fn state(&self) -> &FormatState<Self::Context>
Returns the formatting state relevant for this formatting session.
source§fn state_mut(&mut self) -> &mut FormatState<Self::Context>
fn state_mut(&mut self) -> &mut FormatState<Self::Context>
Returns the mutable formatting state relevant for this formatting session.
source§fn snapshot(&self) -> BufferSnapshot
fn snapshot(&self) -> BufferSnapshot
Takes a snapshot of the Buffers state, excluding the formatter state.
source§fn restore_snapshot(&mut self, snapshot: BufferSnapshot)
fn restore_snapshot(&mut self, snapshot: BufferSnapshot)
Restores the snapshot buffer Read more
Auto Trait Implementations§
impl<'a, Context> Freeze for RemoveSoftLinesBuffer<'a, Context>
impl<'a, Context> !RefUnwindSafe for RemoveSoftLinesBuffer<'a, Context>
impl<'a, Context> !Send for RemoveSoftLinesBuffer<'a, Context>
impl<'a, Context> !Sync for RemoveSoftLinesBuffer<'a, Context>
impl<'a, Context> Unpin for RemoveSoftLinesBuffer<'a, Context>
impl<'a, Context> !UnwindSafe for RemoveSoftLinesBuffer<'a, Context>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> BufferExtensions for Twhere
T: Buffer,
impl<T> BufferExtensions for Twhere
T: Buffer,
source§fn inspect<F>(&mut self, inspector: F) -> Inspect<'_, Self::Context, F>where
F: FnMut(&FormatElement),
fn inspect<F>(&mut self, inspector: F) -> Inspect<'_, Self::Context, F>where
F: FnMut(&FormatElement),
Returns a new buffer that calls the passed inspector for every element that gets written to the output
source§fn start_recording(&mut self) -> Recording<'_, Self>
fn start_recording(&mut self) -> Recording<'_, Self>
Starts a recording that gives you access to all elements that have been written between the start
and end of the recording Read more
source§fn write_elements<I>(&mut self, elements: I) -> FormatResult<()>where
I: IntoIterator<Item = FormatElement>,
fn write_elements<I>(&mut self, elements: I) -> FormatResult<()>where
I: IntoIterator<Item = FormatElement>,
Writes a sequence of elements into this buffer.