Skip to main content

Slots

Struct Slots 

pub struct Slots<T> { /* private fields */ }
Expand description

A generational slot map. Generation zero is reserved for protocol control values; exhausted generations retire their slot rather than wrapping and reviving an old id.

Implementations§

§

impl<T> Slots<T>

pub fn insert(&mut self, value: T) -> Id

A value that lives until the call returns.

pub fn insert_long(&mut self, value: T) -> Id

A value that lives until remove.

pub fn get(&self, id: Id) -> Result<&T, Stale>

The value, or Stale.

pub fn get_mut(&mut self, id: Id) -> Result<&mut T, Stale>

The value to change, or Stale.

pub fn remove(&mut self, id: Id) -> Result<T, Stale>

Frees the slot and returns its value; the id is stale from now on.

pub fn end_frame(&mut self)

Frees every value of this call; long-lived ones stay.

Trait Implementations§

§

impl<T> Default for Slots<T>

§

fn default() -> Slots<T>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Slots<T>

§

impl<T> RefUnwindSafe for Slots<T>
where T: RefUnwindSafe,

§

impl<T> Send for Slots<T>
where T: Send,

§

impl<T> Sync for Slots<T>
where T: Sync,

§

impl<T> Unpin for Slots<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Slots<T>

§

impl<T> UnwindSafe for Slots<T>
where T: UnwindSafe,

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.