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
as_mut_slicemust return the same slice asBuffer::as_slice- The full buffer slice must have at least
capacitymaybe uninitialized items;as_mut_slicereturns in fact the beginning of the full slice. - Accessing
capacitymust not invalidate the buffer slice. - If
set_lenreturnstrue, then the length ofas_mut_slicemust have been updated accordingly. - If
try_reservereturns successfully, thencapacitymust have been increased by at leastadditionalitems. - If the buffer implements
BorrowMetadata, thenborrow_metadatamust not invalidate the buffer slice.
Required Methods§
Sourcefn as_mut_slice(&mut self) -> &mut S
fn as_mut_slice(&mut self) -> &mut S
Returns the mutable buffer slice.
Sourceunsafe fn set_len(&mut self, len: usize) -> bool
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.
Sourcefn try_reserve(&mut self, additional: usize) -> Result<(), TryReserveError>
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.