Skip to main content

PokeList

Struct PokeList 

Source
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>

Source

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.

Source

pub fn len(&self) -> usize

Get the length of the list

Source

pub fn is_empty(&self) -> bool

Returns true if the list is empty

Source

pub fn get(&self, index: usize) -> Option<Peek<'_, 'facet>>

Get an immutable reference to an item from the list at the specified index

Source

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

Source

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.

Source

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.

Source

pub fn push_from_heap<const BORROW: bool>( &mut self, value: HeapValue<'facet, BORROW>, ) -> Result<(), ReflectError>

Type-erased push.

Accepts a HeapValue whose shape must match the list’s element type. The value is moved out of the HeapValue into the list.

Source

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.

Source

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.

Source

pub const fn def(&self) -> ListDef

Def getter

Source

pub fn into_inner(self) -> Poke<'mem, 'facet>

Converts this PokeList back into a Poke

Source

pub fn as_peek_list(&self) -> PeekList<'_, 'facet>

Returns a read-only PeekList view

Trait Implementations§

Source§

impl Debug for PokeList<'_, '_>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'mem, 'facet> Freeze for PokeList<'mem, 'facet>

§

impl<'mem, 'facet> RefUnwindSafe for PokeList<'mem, 'facet>

§

impl<'mem, 'facet> !Send for PokeList<'mem, 'facet>

§

impl<'mem, 'facet> !Sync for PokeList<'mem, 'facet>

§

impl<'mem, 'facet> Unpin for PokeList<'mem, 'facet>

§

impl<'mem, 'facet> UnsafeUnpin for PokeList<'mem, 'facet>

§

impl<'mem, 'facet> !UnwindSafe for PokeList<'mem, 'facet>

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> 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, 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.