#[repr(C)]pub struct TypedArray<T> {
pub header: HeapHeader,
pub data: *mut T,
pub len: u32,
pub cap: u32,
}Expand description
Typed contiguous array with refcounted header.
Allocated on the heap via raw allocator. The data pointer points to a
separate allocation holding cap elements of type T.
Fields§
§header: HeapHeader8-byte v2 heap header (refcount at offset 0).
data: *mut TPointer to contiguous T buffer.
len: u32Number of elements currently stored.
cap: u32Allocated capacity in number of elements.
Implementations§
Source§impl<T: Copy> TypedArray<T>
impl<T: Copy> TypedArray<T>
Sourcepub fn new() -> *mut Self
pub fn new() -> *mut Self
Allocate a new empty TypedArray with capacity 0.
Returns a raw pointer to the heap-allocated array. The caller is
responsible for eventually calling drop_array to free it.
Sourcepub fn with_capacity(cap: u32) -> *mut Self
pub fn with_capacity(cap: u32) -> *mut Self
Allocate a new TypedArray with the given capacity.
Returns a raw pointer to the heap-allocated array.
Sourcepub fn from_slice(slice: &[T]) -> *mut Self
pub fn from_slice(slice: &[T]) -> *mut Self
Create a TypedArray from a slice, copying all elements.
Sourcepub unsafe fn get(this: *const Self, index: u32) -> Option<T>
pub unsafe fn get(this: *const Self, index: u32) -> Option<T>
Get an element by index, returning None if out of bounds.
§Safety
this must point to a valid, live TypedArray<T>.
Sourcepub unsafe fn get_unchecked(this: *const Self, index: u32) -> T
pub unsafe fn get_unchecked(this: *const Self, index: u32) -> T
Get an element by index without bounds checking.
§Safety
this must point to a valid, live TypedArray<T>, and index must
be less than the array’s length.
Sourcepub unsafe fn set(this: *mut Self, index: u32, val: T)
pub unsafe fn set(this: *mut Self, index: u32, val: T)
Set an element by index. Panics if out of bounds.
§Safety
this must point to a valid, live TypedArray<T>.
Sourcepub unsafe fn push(this: *mut Self, val: T)
pub unsafe fn push(this: *mut Self, val: T)
Push an element, growing the buffer if necessary (doubling strategy).
§Safety
this must point to a valid, live TypedArray<T>.
Sourcepub unsafe fn pop(this: *mut Self) -> Option<T>
pub unsafe fn pop(this: *mut Self) -> Option<T>
Pop the last element, returning None if empty.
§Safety
this must point to a valid, live TypedArray<T>.
Sourcepub unsafe fn as_mut_slice<'a>(this: *mut Self) -> &'a mut [T]
pub unsafe fn as_mut_slice<'a>(this: *mut Self) -> &'a mut [T]
Sourcepub unsafe fn drop_array(ptr: *mut Self)
pub unsafe fn drop_array(ptr: *mut Self)
Deallocate the array and its data buffer.
§Safety
ptr must point to a TypedArray<T> that was allocated by this module.
After calling this, ptr is invalid.
Source§impl<T: HeapElement> TypedArray<*const T>
Heap-element-aware drop dispatch for TypedArray<*const T> where T: HeapElement.
impl<T: HeapElement> TypedArray<*const T>
Heap-element-aware drop dispatch for TypedArray<*const T> where T: HeapElement.
Per ADR-006 §2.7.24 Q25.A SUPERSEDED + R20 S2-prime audit deliverable (b)
§4.1.B decision: drop_array_heap walks the element buffer and calls
T::release_elem(elem_ptr) for each stored pointer, then frees the data
buffer + the TypedArray struct itself. Per-T dispatch is monomorphized at
compile time via the HeapElement trait — no runtime NativeKind probe.
Pairs with the POD-element drop_array for T: Copy (above). Callers
pick at compile time based on whether the element type is POD (plain
scalar like f64/i64) or HeapHeader-equipped (*const StringObj /
*const DecimalObj / …).
Sourcepub unsafe fn drop_array_heap(ptr: *mut Self)
pub unsafe fn drop_array_heap(ptr: *mut Self)
Deallocate the array, releasing per-element shares via
T::release_elem, then freeing the data buffer + the struct.
§Safety
ptr must point to a TypedArray<*const T> that was allocated by
this module. Each stored *const T must be a valid pointer to a
live T allocation with at least one refcount share owned by this
array. After this call, ptr is invalid.
Source§impl<T> TypedArray<T>
impl<T> TypedArray<T>
Sourcepub fn new_generic() -> *mut Self
pub fn new_generic() -> *mut Self
Allocate a new empty TypedArray with capacity 0 — non-Copy variant.
Returns a raw pointer to the heap-allocated array. The caller is
responsible for eventually freeing it via HashMapValueElem:: release_typed_array (for HashMapData<V> value buffers) or the
equivalent per-T release path.
Sourcepub fn with_capacity_generic(cap: u32) -> *mut Self
pub fn with_capacity_generic(cap: u32) -> *mut Self
Allocate a new TypedArray with the given capacity — non-Copy variant.
Returns a raw pointer to the heap-allocated array. No elements are
written; the data buffer is uninitialized memory of length cap * size_of::<T>().
Sourcepub unsafe fn len_generic(this: *const Self) -> u32
pub unsafe fn len_generic(this: *const Self) -> u32
Get the number of elements — non-Copy variant.
§Safety
this must point to a valid, live TypedArray<T>.
Sourcepub unsafe fn capacity_generic(this: *const Self) -> u32
pub unsafe fn capacity_generic(this: *const Self) -> u32
Get the allocated capacity — non-Copy variant.
§Safety
this must point to a valid, live TypedArray<T>.
Sourcepub unsafe fn is_empty_generic(this: *const Self) -> bool
pub unsafe fn is_empty_generic(this: *const Self) -> bool
Check if the array is empty — non-Copy variant.
§Safety
this must point to a valid, live TypedArray<T>.
Sourcepub unsafe fn as_slice_generic<'a>(this: *const Self) -> &'a [T]
pub unsafe fn as_slice_generic<'a>(this: *const Self) -> &'a [T]
Get the elements as a slice — non-Copy variant.
§Safety
this must point to a valid, live TypedArray<T>.