pub struct StrBuffer<const N: usize> { /* private fields */ }Expand description
Fixed-size stack-allocated string buffer.
StrBuffer<N> stores up to N bytes of valid UTF-8 on the stack without heap allocation.
Used internally by streaming formatters (e.g., HTML unescape) to buffer partial output
across format_with chunk boundaries.
§Design note
This exists because streaming Display wrappers receive output in arbitrary-sized chunks
via fmt::Write::write_str. When a multi-byte entity (like &) is split across two
chunks, the buffer accumulates bytes until the entity is complete. The const-generic size
N is chosen per use site to match the longest possible entity.
Implementations§
Source§impl<const N: usize> StrBuffer<N>
impl<const N: usize> StrBuffer<N>
pub fn new() -> Self
pub fn push_str<'s>(&mut self, s: &'s str) -> Result<(), &'s str>
pub fn as_str(&self) -> &str
pub fn clear(&mut self)
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn first(&self) -> Option<&str>
pub fn strip_first(&mut self) -> Option<()>
Trait Implementations§
impl<const N: usize> Eq for StrBuffer<N>
impl<const N: usize> StructuralPartialEq for StrBuffer<N>
Auto Trait Implementations§
impl<const N: usize> Freeze for StrBuffer<N>
impl<const N: usize> RefUnwindSafe for StrBuffer<N>
impl<const N: usize> Send for StrBuffer<N>
impl<const N: usize> Sync for StrBuffer<N>
impl<const N: usize> Unpin for StrBuffer<N>
impl<const N: usize> UnsafeUnpin for StrBuffer<N>
impl<const N: usize> UnwindSafe for StrBuffer<N>
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