[][src]Struct slots::Slots

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

A type-checked slab allocator with predetermined size

The allocator deals out Key objects that can be used to access the data later through a (shared or mutable) reference to the Slots. By the interface's design, access is guaranteed to succeed, as the keys are unclonable and consumed to remove an item from the Slots instance.

Methods

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

pub fn new() -> Self[src]

Create an empty slot allocator of size N.

If the verify_owner feature is enabled, it will carry a new unique (except for wraparounds) ID which it shares with its keys.

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

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

pub fn store(&mut self, item: IT) -> Result<Key<IT, N>, 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, key: Key<IT, N>) -> IT[src]

Move an item out of its slot

pub fn read<T, F>(&self, key: &Key<IT, N>, function: F) -> T where
    F: FnOnce(&IT) -> T, 
[src]

Provide immutable access to an item

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

Opportunistic immutable access to an item by its index

A suitable index can be generated from a Key through its index() method; unlike the regular access, this can fail if the element has been removed (in which case the function is not run at all), or might have been replaced by a completely unrelated element inbetween.

pub fn modify<T, F>(&mut self, key: &Key<IT, N>, function: F) -> T where
    F: FnOnce(&mut IT) -> T, 
[src]

Provide mutable access to an item

Auto Trait Implementations

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

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

impl<IT, N> Unpin for Slots<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.