#[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, its length and the capacity of the vector it was allocated from.
§Safety
Changing the values here may lead to undefined behavior when the memory is dropped.
Fields§
§ptr: *mut c_voidOpaque pointer to block of memory storing elements to access the elements cast it to the underlying type.
len: usizeThe number of elements in the block.
cap: usizeThe capacity of vector from which it was allocated. Used when deallocating the memory
Implementations§
Trait Implementations§
Source§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<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
Auto Trait Implementations§
impl Freeze for CVec
impl RefUnwindSafe for CVec
impl !Sync for CVec
impl Unpin for CVec
impl UnwindSafe for CVec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more