[][src]Struct slots::RawSlots

pub struct RawSlots<IT, N> where
    N: ArrayLength<Entry<IT>> + Unsigned, 
{ /* fields omitted */ }

An unchecked slab allocator with predetermined size

The allocator deals out usize handles that can be used to access the data later through a (shared or mutable) reference to the RawSlots. All access is fallible, as the handles can be arbitrarily created.

It is up to slots' users to ensure that the item they intend to access is still identified by that handle, especially as it can have been removed in the meantime, and the handle replaced by a different object.

Methods

impl<IT, N> RawSlots<IT, N> where
    N: ArrayLength<Entry<IT>> + Unsigned, 
[src]

pub fn new() -> Self[src]

Create an empty raw slot allocator of size N.

pub fn capacity(&self) -> usize[src]

pub fn count(&self) -> usize[src]

pub fn store(&mut self, item: IT) -> Result<usize, IT>[src]

Put an item into a free slot

This returns an access index for the stored data in the success case, or hands the unstored item back in case of an error.

pub fn take(&mut self, index: usize) -> Option<IT>[src]

Move an item out of a slot, if it exists

pub fn read<T, F>(&self, index: usize, function: F) -> Option<T> where
    F: FnOnce(&IT) -> T, 
[src]

Provide immutable access to an item

The callback is only run if the given index is currently valid.

pub fn modify<T, F>(&mut self, index: usize, function: F) -> Option<T> where
    F: FnOnce(&mut IT) -> T, 
[src]

Provide mutable access to an item The callback is only run if the given index is currently valid.

Auto Trait Implementations

impl<IT, N> Send for RawSlots<IT, N> where
    IT: Send

impl<IT, N> Sync for RawSlots<IT, N> where
    IT: Sync

impl<IT, N> Unpin for RawSlots<IT, N> where
    <N as ArrayLength<Entry<IT>>>::ArrayType: Unpin

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.