pub struct Slot<'frame, T> { /* private fields */ }
Expand description
An empty slot on the stack into which a value could be emplaced.
The 'frame
lifetime refers to the lifetime of the stack frame this
Slot
’s storage is allocated on.
See slot!()
and the module documentation.
Implementations§
Source§impl<'frame, T> Slot<'frame, T>
impl<'frame, T> Slot<'frame, T>
Sourcepub unsafe fn new_unchecked(
ptr: &'frame mut MaybeUninit<T>,
drop_flag: DropFlag<'frame>,
) -> Self
pub unsafe fn new_unchecked( ptr: &'frame mut MaybeUninit<T>, drop_flag: DropFlag<'frame>, ) -> Self
Creates a new Slot
with the given pointer as its basis.
To safely construct a Slot
, 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
.
Sourcepub fn put(self, val: T) -> MoveRef<'frame, T>
pub fn put(self, val: T) -> MoveRef<'frame, T>
Put val
into this slot, returning a new MoveRef
.
Sourcepub fn pin(self, val: T) -> Pin<MoveRef<'frame, T>>
pub fn pin(self, val: T) -> Pin<MoveRef<'frame, T>>
Pin val
into this slot, returning a new, pinned MoveRef
.
Sourcepub fn emplace<N: New<Output = T>>(self, new: N) -> Pin<MoveRef<'frame, T>>
pub fn emplace<N: New<Output = T>>(self, new: N) -> Pin<MoveRef<'frame, T>>
Emplace new
into this slot, returning a new, pinned MoveRef
.
Sourcepub fn try_emplace<N: TryNew<Output = T>>(
self,
new: N,
) -> Result<Pin<MoveRef<'frame, T>>, N::Error>
pub fn try_emplace<N: TryNew<Output = T>>( self, new: N, ) -> Result<Pin<MoveRef<'frame, T>>, N::Error>
Try to emplace new
into this slot, returning a new, pinned MoveRef
.
Sourcepub fn into_pinned(self) -> Slot<'frame, Pin<T>>
pub fn into_pinned(self) -> Slot<'frame, Pin<T>>
Converts this into a slot for a pinned T
.
This is safe, since this Slot
owns the referenced data, and
Pin
is explicitly a repr(transparent)
type.
Source§impl<'frame, T> Slot<'frame, Pin<T>>
impl<'frame, T> Slot<'frame, Pin<T>>
Sourcepub fn into_unpinned(self) -> Slot<'frame, T>
pub fn into_unpinned(self) -> Slot<'frame, T>
Converts this into a slot for an unpinned T
.
This is safe, since this Slot
owns the referenced data, and
Pin
is explicitly a repr(transparent)
type.
Moreover, no actual unpinning is occurring: the referenced data must be uninitialized, so it cannot have a pinned referent.