Trait any_vec::mem::Mem

source ·
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§

source

fn as_ptr(&self) -> *const u8

source

fn as_mut_ptr(&mut self) -> *mut u8

source

fn element_layout(&self) -> Layout

Aligned.

source

fn size(&self) -> usize

In elements.

Provided Methods§

source

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.

Implementors§