Struct moveit::slot::DroppingSlot

source ·
pub struct DroppingSlot<'frame, T> { /* private fields */ }
Expand description

Similar to a Slot, but able to drop its contents.

A DroppingSlot wraps a Slot, and will drop its contents if the Slot’s drop flag is dead at the time of the DroppingSlot’s destruction.

This type has an API similar to Slot’s, but rather than returning MoveRefs, which would own the contents of this slot, we return a &mut T and a DropFlag, which the caller can assemble into an appropriately-shaped MoveRef. The drop flag will be one decrement away from being dead; callers should make sure to decremement it to trigger destruction.

DroppingSlot is intended to be used with DerefMove::deref_move(), and will usually not be created by moveit’s users. However, slot!() provides DroppingSlot support, too. These slots will silently forget their contents if the drop flag is left untouched, rather than crash.

Implementations§

source§

impl<'frame, T> DroppingSlot<'frame, T>

source

pub unsafe fn new_unchecked( ptr: &'frame mut MaybeUninit<T>, drop_flag: DropFlag<'frame> ) -> Self

Creates a new DroppingSlot with the given pointer as its basis.

To safely construct a DroppingSlot, use slot!().

Safety

ptr must not be outlived by any other pointers to its allocation.

drop_flag’s value must be dead, and must be a drop flag governing the destruction of ptr’s storage in an appropriate manner as described in moveit::drop_flag.

source

pub fn put(self, val: T) -> (&'frame mut T, DropFlag<'frame>)

Put val into this slot, returning a reference to it.

source

pub unsafe fn pin(self, val: T) -> (Pin<&'frame mut T>, DropFlag<'frame>)

Pin val into this slot, returning a reference to it.

Safety

This function pins the memory this slot wraps, but does not guarantee its destructor is run; that is the caller’s responsibility, by decrementing the given DropFlag.

source

pub unsafe fn emplace<N: New<Output = T>>( self, new: N ) -> (Pin<&'frame mut T>, DropFlag<'frame>)

Emplace new into this slot, returning a reference to it.

Safety

This function pins the memory this slot wraps, but does not guarantee its destructor is run; that is the caller’s responsibility, by decrementing the given DropFlag.

source

pub unsafe fn try_emplace<N: TryNew<Output = T>>( self, new: N ) -> Result<(Pin<&'frame mut T>, DropFlag<'frame>), N::Error>

Try to emplace new into this slot, returning a reference to it.

Safety

This function pins the memory this slot wraps, but does not guarantee its destructor is run; that is the caller’s responsibility, by decrementing the given DropFlag.

Auto Trait Implementations§

§

impl<'frame, T> !RefUnwindSafe for DroppingSlot<'frame, T>

§

impl<'frame, T> !Send for DroppingSlot<'frame, T>

§

impl<'frame, T> !Sync for DroppingSlot<'frame, T>

§

impl<'frame, T> Unpin for DroppingSlot<'frame, T>

§

impl<'frame, T> !UnwindSafe for DroppingSlot<'frame, T>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.