pub struct Buffer { /* private fields */ }
Expand description
Buffer for rendered contents
This struct is quite simular to String
, but some methods are
re-implemented for faster buffering.
Implementations§
source§impl Buffer
impl Buffer
sourcepub fn with_capacity(n: usize) -> Buffer
pub fn with_capacity(n: usize) -> Buffer
Create a empty buffer with a particular capacity
sourcepub fn as_mut_ptr(&self) -> *mut u8
pub fn as_mut_ptr(&self) -> *mut u8
Returns an unsafe mutable pointer to the inner data
sourcepub unsafe fn advance(&mut self, additional: usize)
pub unsafe fn advance(&mut self, additional: usize)
Increase the length of buffer by additional
bytes
Safety
additional
must be less than or equal tocapacity() - len()
- The elements at
old_len..old_len + additional
must be initialized
sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true
if this buffer has a length of zero, and false
otherwise
sourcepub fn into_string(self) -> String
pub fn into_string(self) -> String
Converts a Buffer
into a String
without copy/realloc operation.
Trait Implementations§
source§impl AddAssign<&str> for Buffer
impl AddAssign<&str> for Buffer
source§fn add_assign(&mut self, other: &str)
fn add_assign(&mut self, other: &str)
Performs the
+=
operation. Read moresource§impl Write for Buffer
impl Write for Buffer
impl Send for Buffer
impl Sync for Buffer
Auto Trait Implementations§
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