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§
impl Freeze for Buffer
impl RefUnwindSafe for Buffer
impl Unpin for Buffer
impl UnwindSafe for Buffer
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