BufferMut

Trait BufferMut 

Source
pub unsafe trait BufferMut<S: ?Sized>: Buffer<S> {
    // Required methods
    fn as_mut_slice(&mut self) -> &mut S;
    fn capacity(&self) -> usize;
    unsafe fn set_len(&mut self, len: usize) -> bool;
    fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>;
}
Expand description

A buffer that contains a mutable slice.

The buffer may be resizable, and the whole slice may have an uninitialized section.

§Safety

Required Methods§

Source

fn as_mut_slice(&mut self) -> &mut S

Returns the mutable buffer slice.

Source

fn capacity(&self) -> usize

Returns the buffer capacity.

Source

unsafe fn set_len(&mut self, len: usize) -> bool

Set the length of the buffer slice.

Returns false if this operation is not supported, for example for fixed size buffers like AsMutBuffer.

§Safety

First len items of buffer slice must be initialized.

Source

fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>

Tries reserving capacity for at least additional items.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl BufferMut<str> for String

Source§

fn as_mut_slice(&mut self) -> &mut str

Source§

fn capacity(&self) -> usize

Source§

unsafe fn set_len(&mut self, len: usize) -> bool

Source§

fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>

Source§

impl BufferMut<BStr> for BString

Available on crate feature bstr only.
Source§

fn as_mut_slice(&mut self) -> &mut BStr

Source§

fn capacity(&self) -> usize

Source§

unsafe fn set_len(&mut self, len: usize) -> bool

Source§

fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>

Source§

impl<T: Send + Sync + 'static> BufferMut<[T]> for Vec<T>

Source§

fn as_mut_slice(&mut self) -> &mut [T]

Source§

fn capacity(&self) -> usize

Source§

unsafe fn set_len(&mut self, len: usize) -> bool

Source§

fn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>

Implementors§

Source§

impl<S: Slice + ?Sized, B: AsRef<S> + AsMut<S> + Send + Sync + 'static> BufferMut<S> for AsMutBuffer<B>

SAFETY: Trait contract is upheld by AsMutBuffer::new contract.