pub trait Mem {
// Required methods
fn as_ptr(&self) -> *const u8;
fn as_mut_ptr(&mut self) -> *mut u8;
fn element_layout(&self) -> Layout;
fn size(&self) -> usize;
// Provided method
fn expand(&mut self, additional: usize) { ... }
}
Expand description
Interface for AnyVec
memory chunk.
Responsible for allocation, dealocation, reallocation of the memory chunk.
Constructed through MemBuilder
.
Mem
is fixed capacity memory. Implement MemResizable
if you want it
to be resizable.
Required Methods§
fn as_ptr(&self) -> *const u8
fn as_mut_ptr(&mut self) -> *mut u8
sourcefn element_layout(&self) -> Layout
fn element_layout(&self) -> Layout
Aligned.
Provided Methods§
sourcefn expand(&mut self, additional: usize)
fn expand(&mut self, additional: usize)
Expand Mem
size for at least additional
more elements.
Implementation encouraged to avoid frequent reallocations.
§Notes
Consider, that expand
is in MemResizable
.
Implement this only if your type MemResizable
.
It’s here, only due to technical reasons (see AnyVecRaw::reserve
).
Rust does not support specialization
§Panics
Implementation may panic, if fail to allocate/reallocate memory.