[−][src]Struct slots::RawSlots
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]
N: ArrayLength<Entry<IT>> + Unsigned,
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]
F: FnOnce(&IT) -> T,
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]
F: FnOnce(&mut IT) -> T,
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,
IT: Send,
impl<IT, N> Sync for RawSlots<IT, N> where
IT: Sync,
IT: Sync,
impl<IT, N> Unpin for RawSlots<IT, N> where
<N as ArrayLength<Entry<IT>>>::ArrayType: Unpin,
<N as ArrayLength<Entry<IT>>>::ArrayType: Unpin,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
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]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,