#[repr(C)]pub struct CVec {
pub ptr: *mut c_void,
pub len: usize,
pub cap: usize,
}
Expand description
CVec
is a C compatible struct that stores an opaque pointer to a block of
memory, it’s length and the capacity of the vector it was allocated from.
NOTE: Changing the values here may lead to undefined behavior when the memory is dropped.
Fields§
§ptr: *mut c_void
Opaque pointer to block of memory storing elements to access the elements cast it to the underlying type.
len: usize
The number of elements in the block.
cap: usize
The capacity of vector from which it was allocated. Used when deallocating the memory
Implementations§
Trait Implementations§
Source§impl<T> From<Vec<T>> for CVec
impl<T> From<Vec<T>> for CVec
Consumes and leaks the Vec, returning a mutable pointer to the contents as
a CVec
. The memory has been leaked and now exists for the lifetime of the
program unless dropped manually.
Note: drop the memory by reconstructing the vec using from_raw_parts
method
as shown in the test below.
impl Copy for CVec
impl Send for CVec
Empty derivation for Send to satisfy pyclass
requirements
however this is only designed for single threaded use for now