#[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 createVec<T>::with_capacitypush: Needs to callVec<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
listmust point to an initialized listitemmust 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
listmust point to an initialized listlenmust not exceed the list’s capacity- All elements at indices
0..lenmust 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
listmust 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
impl ListTypeOps
Sourcepub const fn new(iter_vtable: IterVTable<PtrConst>) -> ListTypeOps
pub const fn new(iter_vtable: IterVTable<PtrConst>) -> ListTypeOps
Create a new ListTypeOps with required iterator vtable.
Sourcepub const fn builder() -> ListTypeOpsBuilder
pub const fn builder() -> ListTypeOpsBuilder
Start building a ListTypeOps.
Trait Implementations§
Source§impl Clone for ListTypeOps
impl Clone for ListTypeOps
Source§fn clone(&self) -> ListTypeOps
fn clone(&self) -> ListTypeOps
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more