#[unsafe(no_mangle)]pub const extern "C" fn nstd_vec_new(
allocator: &NSTDAllocator,
stride: NSTDUInt,
align: NSTDUInt,
) -> NSTDVec<'_>Available on crate feature
vec only.Expand description
Creates a new vector without allocating any resources.
§Parameters:
-
const NSTDAllocator *allocator- The memory allocator. -
NSTDUInt stride- The size in bytes of each value in the vector. -
NSTDUInt align- The alignment of each value in the vector.
§Returns
NSTDVec vec - The new vector.
§Panics
This operation will panic if either align is not a power of two or stride is not a multiple
of align.
§Example
use nstd_sys::{alloc::NSTD_ALLOCATOR, vec::nstd_vec_new};
const SIZE: usize = core::mem::size_of::<u32>();
const ALIGN: usize = core::mem::align_of::<u32>();
let vec = unsafe { nstd_vec_new(&NSTD_ALLOCATOR, SIZE, ALIGN) };