[−][src]Struct slab::Slab
A preallocated chunk of memory for storing objects of the same type.
Methods
impl<T, I> Slab<T, I>
[src][−]
pub fn with_capacity(capacity: usize) -> Slab<T, I>
[src][−]
Returns an empty Slab
with the requested capacity
pub fn len(&self) -> usize
[src][−]
Returns the number of values stored by the Slab
pub fn capacity(&self) -> usize
[src][−]
Returns the total capacity of the Slab
pub fn is_empty(&self) -> bool
[src][−]
Returns true if the Slab
is storing no values
pub fn available(&self) -> usize
[src][−]
Returns the number of available slots remaining in the Slab
pub fn has_available(&self) -> bool
[src][−]
Returns true if the Slab
has available slots
impl<T, I: Into<usize> + From<usize>> Slab<T, I>
[src][−]
pub fn contains(&self, idx: I) -> bool
[src][−]
Returns true if the Slab
contains a value for the given token
pub fn get(&self, idx: I) -> Option<&T>
[src][−]
Get a reference to the value associated with the given token
pub fn get_mut(&mut self, idx: I) -> Option<&mut T>
[src][−]
Get a mutable reference to the value associated with the given token
pub fn insert(&mut self, val: T) -> Result<I, T>
[src][−]
Insert a value into the slab, returning the associated token
pub fn entry(&mut self, idx: I) -> Option<Entry<T, I>>
[src][−]
Returns a handle to an entry.
This allows more advanced manipulation of the value stored at the given index.
pub fn vacant_entry(&mut self) -> Option<VacantEntry<T, I>>
[src][−]
Returns a handle to a vacant entry.
This allows optionally inserting a value that is constructed with the index.
pub fn remove(&mut self, idx: I) -> Option<T>
[src][−]
Releases the given slot
pub fn retain<F>(&mut self, f: F) where
F: FnMut(&T) -> bool,
[src][−]
F: FnMut(&T) -> bool,
Retain only the elements specified by the predicate.
In other words, remove all elements e
such that f(&e)
returns false.
This method operates in place and preserves the order of the retained
elements.
pub fn iter(&self) -> Iter<T, I>
[src][−]
An iterator for visiting all elements stored in the Slab
pub fn iter_mut(&mut self) -> IterMut<T, I>
[src][−]
A mutable iterator for visiting all elements stored in the Slab
pub fn clear(&mut self)
[src][−]
Empty the slab, by freeing all entries
pub fn reserve_exact(&mut self, additional: usize)
[src][−]
Reserves the minimum capacity for exactly additional
more elements to
be inserted in the given Slab
. Does nothing if the capacity is
already sufficient.
Trait Implementations
impl<T, I> Debug for Slab<T, I> where
T: Debug,
I: Debug,
[src][+]
T: Debug,
I: Debug,
impl<T, I: From<usize> + Into<usize>> Index<I> for Slab<T, I>
[src][+]
impl<T, I: From<usize> + Into<usize>> IndexMut<I> for Slab<T, I>
[src][+]
impl<'a, T, I: From<usize> + Into<usize>> IntoIterator for &'a Slab<T, I>
[src][+]
impl<'a, T, I: From<usize> + Into<usize>> IntoIterator for &'a mut Slab<T, I>
[src][+]
impl<T, I> Send for Slab<T, I> where
T: Send,
[src]
T: Send,
Auto Trait Implementations
impl<T, I> RefUnwindSafe for Slab<T, I> where
I: RefUnwindSafe,
T: RefUnwindSafe,
I: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, I> Sync for Slab<T, I> where
I: Sync,
T: Sync,
I: Sync,
T: Sync,
impl<T, I> Unpin for Slab<T, I> where
I: Unpin,
T: Unpin,
I: Unpin,
T: Unpin,
impl<T, I> UnwindSafe for Slab<T, I> where
I: UnwindSafe,
T: UnwindSafe,
I: UnwindSafe,
T: UnwindSafe,
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,
impl<T> From<T> for T
[src][+]
impl<T, U> Into<U> for T where
U: From<T>,
[src][+]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src][+]
U: Into<T>,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src][+]
U: TryFrom<T>,