pub struct PokeList<'mem, 'facet> { /* private fields */ }Expand description
Lets you mutate a list (implements mutable facet_core::ListVTable proxies)
Implementations§
Source§impl<'mem, 'facet> PokeList<'mem, 'facet>
impl<'mem, 'facet> PokeList<'mem, 'facet>
Sourcepub const unsafe fn new(value: Poke<'mem, 'facet>, def: ListDef) -> Self
pub const unsafe fn new(value: Poke<'mem, 'facet>, def: ListDef) -> Self
Creates a new poke list
§Safety
The caller must ensure that def contains valid vtable function pointers that:
- Correctly implement the list operations for the actual type
- Do not cause undefined behavior when called
- Return pointers within valid memory bounds
- Match the element type specified in
def.t()
Violating these requirements can lead to memory safety issues.
Sourcepub fn get(&self, index: usize) -> Option<Peek<'_, 'facet>>
pub fn get(&self, index: usize) -> Option<Peek<'_, 'facet>>
Get an immutable reference to an item from the list at the specified index
Sourcepub fn get_mut(&mut self, index: usize) -> Option<Poke<'_, 'facet>>
pub fn get_mut(&mut self, index: usize) -> Option<Poke<'_, 'facet>>
Get a mutable reference to an item from the list at the specified index
Sourcepub fn iter_mut(self) -> Result<PokeListIter<'mem, 'facet>, ReflectError>
pub fn iter_mut(self) -> Result<PokeListIter<'mem, 'facet>, ReflectError>
Returns a mutable iterator over the list.
Requires contiguous mutable access: the element type must be sized and the list
vtable must expose as_mut_ptr. Returns ReflectErrorKind::OperationFailed otherwise;
use PokeList::get_mut per index when iter_mut is unavailable.
The previous fallback that synthesized a mutable iterator from the list’s iter_vtable
was unsound: that vtable yields PtrConst items backed by shared references, and writing
through them is UB.
Sourcepub fn push<T: Facet<'facet>>(&mut self, value: T) -> Result<(), ReflectError>
pub fn push<T: Facet<'facet>>(&mut self, value: T) -> Result<(), ReflectError>
Push a value onto the end of the list.
Returns an error if the underlying list type does not support push (e.g. immutable lists) or if the value’s shape does not match the list’s element type.
Sourcepub fn push_from_heap<const BORROW: bool>(
&mut self,
value: HeapValue<'facet, BORROW>,
) -> Result<(), ReflectError>
pub fn push_from_heap<const BORROW: bool>( &mut self, value: HeapValue<'facet, BORROW>, ) -> Result<(), ReflectError>
Sourcepub fn pop(&mut self) -> Result<Option<HeapValue<'facet, true>>, ReflectError>
pub fn pop(&mut self) -> Result<Option<HeapValue<'facet, true>>, ReflectError>
Pop the last value off the end of the list.
Returns Ok(None) if the list is empty. Returns an error if the
underlying list type does not support pop.
Sourcepub fn swap(&mut self, a: usize, b: usize) -> Result<(), ReflectError>
pub fn swap(&mut self, a: usize, b: usize) -> Result<(), ReflectError>
Swap the elements at indices a and b.
Returns an error if the underlying list type does not support swap or if either index is out of bounds. Swapping an index with itself is a no-op.
Sourcepub fn into_inner(self) -> Poke<'mem, 'facet>
pub fn into_inner(self) -> Poke<'mem, 'facet>
Converts this PokeList back into a Poke
Sourcepub fn as_peek_list(&self) -> PeekList<'_, 'facet>
pub fn as_peek_list(&self) -> PeekList<'_, 'facet>
Returns a read-only PeekList view