Struct Slot

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

Source

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.

Source

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.

Auto Trait Implementations§

§

impl<'lt, T> Freeze for Slot<'lt, T>

§

impl<'lt, T> !RefUnwindSafe for Slot<'lt, T>

§

impl<'lt, T> !Send for Slot<'lt, T>

§

impl<'lt, T> !Sync for Slot<'lt, T>

§

impl<'lt, T> Unpin for Slot<'lt, T>

§

impl<'lt, T> !UnwindSafe for Slot<'lt, T>

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.