ListTypeOps

Struct ListTypeOps 

Source
#[repr(C)]
pub struct ListTypeOps { pub init_in_place_with_capacity: Option<unsafe fn(PtrUninit, usize) -> PtrMut>, pub push: Option<unsafe fn(PtrMut, PtrMut)>, pub set_len: Option<unsafe fn(PtrMut, usize)>, pub as_mut_ptr_typed: Option<unsafe fn(PtrMut) -> *mut u8>, pub iter_vtable: IterVTable<PtrConst>, }
Expand description

Per-type list operations that must be monomorphized.

These operations cannot be type-erased because they need to know the concrete element type T at compile time:

  • init_in_place_with_capacity: Needs to create Vec<T>::with_capacity
  • push: Needs to call Vec<T>::push
  • Iterator operations: Need the concrete iterator type

This struct is used alongside a shared ListVTable to separate:

  • Shareable operations (in ListVTable): Can be type-erased using runtime shape info (len, get, get_mut, as_ptr, as_mut_ptr)
  • Per-T operations (in ListTypeOps): Must be monomorphized

§Example

// Shared vtable for ALL Vec<T> instantiations
static VEC_LIST_VTABLE: ListVTable = ListVTable { ... };

// Per-T operations for Vec<String>
static VEC_STRING_TYPE_OPS: ListTypeOps = ListTypeOps { ... };

Fields§

§init_in_place_with_capacity: Option<unsafe fn(PtrUninit, usize) -> PtrMut>

Initialize a list in place with a given capacity (per-T).

§Safety

The list parameter must point to uninitialized memory of sufficient size.

§push: Option<unsafe fn(PtrMut, PtrMut)>

Push an item to the list (per-T).

§Safety

  • list must point to an initialized list
  • item must point to an initialized value that will be moved
§set_len: Option<unsafe fn(PtrMut, usize)>

Set the length of the list (per-T, for direct-fill operations).

§Safety

  • list must point to an initialized list
  • len must not exceed the list’s capacity
  • All elements at indices 0..len must be properly initialized
§as_mut_ptr_typed: Option<unsafe fn(PtrMut) -> *mut u8>

Get raw mutable pointer to the data buffer (per-T, for direct-fill).

§Safety

  • list must point to an initialized list
§iter_vtable: IterVTable<PtrConst>

Virtual table for list iterator operations (per-T).

Iterator operations cannot be type-erased because the iterator state (Box<slice::Iter<'_, T>>) is type-specific.

Implementations§

Source§

impl ListTypeOps

Source

pub const fn new(iter_vtable: IterVTable<PtrConst>) -> ListTypeOps

Create a new ListTypeOps with required iterator vtable.

Source

pub const fn builder() -> ListTypeOpsBuilder

Start building a ListTypeOps.

Trait Implementations§

Source§

impl Clone for ListTypeOps

Source§

fn clone(&self) -> ListTypeOps

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 ListTypeOps

Source§

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

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

impl Copy for ListTypeOps

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.