pub struct PokeOption<'mem, 'facet> { /* private fields */ }Expand description
Lets you mutate an option (implements mutable option operations)
Implementations§
Source§impl<'mem, 'facet> PokeOption<'mem, 'facet>
impl<'mem, 'facet> PokeOption<'mem, 'facet>
Sourcepub const unsafe fn new(value: Poke<'mem, 'facet>, def: OptionDef) -> Self
pub const unsafe fn new(value: Poke<'mem, 'facet>, def: OptionDef) -> Self
Creates a new poke option
§Safety
The caller must ensure that def contains valid vtable function pointers that
correctly implement the option operations for the actual type, and that the
inner type matches def.t().
Sourcepub const fn vtable(&self) -> &'static OptionVTable
pub const fn vtable(&self) -> &'static OptionVTable
Returns the option vtable
Sourcepub fn value(&self) -> Option<Peek<'_, 'facet>>
pub fn value(&self) -> Option<Peek<'_, 'facet>>
Returns the inner value as a read-only Peek if the option is Some, None otherwise.
Sourcepub fn value_mut(&mut self) -> Option<Poke<'_, 'facet>>
pub fn value_mut(&mut self) -> Option<Poke<'_, 'facet>>
Returns the inner value as a mutable Poke if the option is Some, None otherwise.
Sourcepub fn set_some<T: Facet<'facet>>(
&mut self,
value: T,
) -> Result<(), ReflectError>
pub fn set_some<T: Facet<'facet>>( &mut self, value: T, ) -> Result<(), ReflectError>
Sets the option to Some(value), dropping the previous value.
Sourcepub fn set_some_from_heap<const BORROW: bool>(
&mut self,
value: HeapValue<'facet, BORROW>,
) -> Result<(), ReflectError>
pub fn set_some_from_heap<const BORROW: bool>( &mut self, value: HeapValue<'facet, BORROW>, ) -> Result<(), ReflectError>
Type-erased set_some.
Accepts a HeapValue whose shape must match the option’s inner type. The value is
moved out of the HeapValue into the option; the HeapValue’s backing memory is freed
without running drop (the vtable has already consumed the value via ptr::read).
Use this when you hold a reflection-built value and can’t produce a concrete T.
Sourcepub const fn into_inner(self) -> Poke<'mem, 'facet>
pub const fn into_inner(self) -> Poke<'mem, 'facet>
Converts this PokeOption back into a Poke
Sourcepub fn as_peek_option(&self) -> PeekOption<'_, 'facet>
pub fn as_peek_option(&self) -> PeekOption<'_, 'facet>
Returns a read-only PeekOption view