pub struct Slot<'lt, T> { /* private fields */ }
Expand description
A stack allocation that one can pin a value into.
This contains two references: One to uninitialized stack allocated memory large enough to store a value of the requested type into, and another reference to the head of a linked list of pinned values. When the caller decides to fill the slot then it is written to the stack memory and prepended to the linked list such that the value is guaranteed to drop before all other values contained in it.
Implementations§
Source§impl<'lt, T> Slot<'lt, T>
impl<'lt, T> Slot<'lt, T>
Sourcepub fn pin(self, value: T) -> Pin<&'lt mut T>where
T: 'static,
pub fn pin(self, value: T) -> Pin<&'lt mut T>where
T: 'static,
Pin a value to the stack.
Returns the value if there is no more space in the reserved portion of memory to pin the
new value. You might try calling pop_all
then to free some.
Note that dropping might be delayed arbitrarily as the ExitStack has no control over its own drop point, hence values must live for a static duration.
Sourcepub unsafe fn pin_local(self, value: T) -> Pin<&'lt mut T>
pub unsafe fn pin_local(self, value: T) -> Pin<&'lt mut T>
Pin a short-lived value to this exit stack.
§Safety
The caller guarantees that the exit stack is dropped before the validity of T
expires.