Slab

Struct Slab 

Source
pub struct Slab<T> { /* private fields */ }

Implementations§

Source§

impl<T> Slab<T>

Source

pub fn new() -> Slab<T>

Creates a new Slab

Source

pub fn with_capacity(capacity: usize) -> Slab<T>

Creates a new, empty Slab with room for capacity elems

§Panics
  • If the host system is out of memory
Source

pub fn insert(&mut self, elem: T)

Inserts a new element into the slab, re-allocating if neccessary.

§Panics
  • If the host system is out of memory.
Source

pub fn remove(&mut self, offset: usize) -> T

Removes the element at offset.

§Panics
  • If offset is out of bounds.
Source

pub fn len(&self) -> usize

Returns the number of elements in the slab

Source

pub fn iter(&self) -> SlabIter<'_, T>

Returns an iterator over the slab

Source

pub fn iter_mut(&mut self) -> SlabMutIter<'_, T>

Returns a mutable iterator over the slab

Trait Implementations§

Source§

impl<T> Drop for Slab<T>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<T> Index<usize> for Slab<T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, T> IntoIterator for &'a Slab<T>

Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

type IntoIter = SlabIter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> SlabIter<'a, T>

Creates an iterator from a value. Read more
Source§

impl<'a, T> IntoIterator for &'a mut Slab<T>

Source§

type Item = &'a mut T

The type of the elements being iterated over.
Source§

type IntoIter = SlabMutIter<'a, T>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> SlabMutIter<'a, T>

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Slab<T>

§

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

§

impl<T> !Send for Slab<T>

§

impl<T> !Sync for Slab<T>

§

impl<T> Unpin for Slab<T>

§

impl<T> UnwindSafe for Slab<T>
where T: RefUnwindSafe,

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.