Skip to main content

ShapeArray

Struct ShapeArray 

Source
pub struct ShapeArray { /* private fields */ }
Expand description

Unified array with C-ABI-stable layout for JIT and VM.

Elements are ValueWord values stored in a contiguous heap buffer. Clone/Drop correctly manage heap-tagged ValueWord reference counts.

Implementations§

Source§

impl ShapeArray

Byte offsets for JIT inline access.

Source

pub const OFFSET_DATA: usize = 0

Byte offset of the data pointer field.

Source

pub const OFFSET_LEN: usize = 8

Byte offset of the len field.

Source

pub const OFFSET_CAP: usize = 16

Byte offset of the cap field.

Source§

impl ShapeArray

Source

pub fn new() -> Self

Create an empty array with no allocation.

Source

pub fn with_capacity(cap: usize) -> Self

Create an array with pre-allocated capacity.

Source

pub fn from_iter(iter: impl IntoIterator<Item = ValueWord>) -> Self

Create an array from an iterator of ValueWord values.

Source

pub fn from_vec(vec: Vec<ValueWord>) -> Self

Create an array from an owned Vec<ValueWord>.

Source

pub fn from_slice(elements: &[ValueWord]) -> Self

Create an array by cloning from a slice of ValueWord.

Source

pub unsafe fn from_raw_u64_slice(elements: &[u64]) -> Self

Create from a raw u64 slice (for JIT interop).

§Safety

The caller must ensure that each u64 is a valid ValueWord bit pattern. For heap-tagged values, the caller must ensure the Arc refcount has been incremented appropriately (or that this array takes ownership).

Source

pub fn len(&self) -> usize

Number of elements.

Source

pub fn is_empty(&self) -> bool

Check if empty.

Source

pub fn capacity(&self) -> usize

Allocated capacity.

Source

pub fn as_slice(&self) -> &[ValueWord]

View elements as a slice.

Source

pub fn as_mut_slice(&mut self) -> &mut [ValueWord]

View elements as a mutable slice.

Source

pub fn as_raw_u64_slice(&self) -> &[u64]

View raw buffer as u64 slice (for JIT interop).

Source

pub fn as_ptr(&self) -> *const ValueWord

Raw pointer to the data buffer (for JIT inline access).

Source

pub fn as_mut_ptr(&mut self) -> *mut ValueWord

Raw mutable pointer to the data buffer (for JIT inline access).

Source

pub fn get(&self, index: usize) -> Option<&ValueWord>

Get element by index (bounds-checked).

Source

pub fn push(&mut self, value: ValueWord)

Push an element (amortized O(1) with doubling growth).

Source

pub fn pop(&mut self) -> Option<ValueWord>

Pop the last element.

Source

pub fn iter(&self) -> Iter<'_, ValueWord>

Iterate over elements.

Source

pub fn first(&self) -> Option<&ValueWord>

Get first element.

Source

pub fn last(&self) -> Option<&ValueWord>

Get last element.

Source

pub fn to_vec(&self) -> Vec<ValueWord>

Convert to Vec (copies the data).

Source

pub fn into_vec(self) -> Vec<ValueWord>

Consume and convert into Vec (transfers ownership, no copy).

Trait Implementations§

Source§

impl Clone for ShapeArray

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ShapeArray

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ShapeArray

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for ShapeArray

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl From<Arc<Vec<ValueWord>>> for ShapeArray

Source§

fn from(arc: Arc<Vec<ValueWord>>) -> Self

Convert from the legacy VMArray (Arc<Vec<ValueWord>>). Clones the elements since the Arc may be shared.

Source§

impl From<ShapeArray> for Vec<ValueWord>

Source§

fn from(arr: ShapeArray) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<ValueWord>> for ShapeArray

Source§

fn from(vec: Vec<ValueWord>) -> Self

Converts to this type from the input type.
Source§

impl Index<usize> for ShapeArray

Source§

type Output = ValueWord

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &ValueWord

Performs the indexing (container[index]) operation. Read more
Source§

impl IndexMut<usize> for ShapeArray

Source§

fn index_mut(&mut self, index: usize) -> &mut ValueWord

Performs the mutable indexing (container[index]) operation. Read more
Source§

impl<'a> IntoIterator for &'a ShapeArray

Source§

type Item = &'a ValueWord

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, ValueWord>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for ShapeArray

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Send for ShapeArray

Source§

impl Sync for ShapeArray

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,