Struct TypePools

Source
pub struct TypePools<H = RandomState> { /* private fields */ }
Expand description

A collection of pools or arrays that contain values of a specific type

Implementations§

Source§

impl TypePools

Source

pub fn new() -> Self

Source

pub fn type_pool<T: 'static>(&self) -> Option<&TypePool<T>>

Get a reference to a type pool

Source

pub fn type_pool_mut<T: 'static>(&mut self) -> Option<&mut TypePool<T>>

Get a mutable reference to a type pool

Source

pub fn push<T: 'static>(&mut self, value: T)

Add a value to the pools. If the type pool doesn’t exst yet, it will be created

Source

pub fn pop<T: 'static>(&mut self) -> Option<T>

Returns the popped item or None if the value doesn’t exist

Source

pub fn remove<T: 'static>(&mut self, idx: usize) -> Option<T>

Remove the value at the index in the type pool specified by T

Source

pub fn get<T: 'static>(&self, idx: usize) -> Option<&T>

Gets a value from a TypePool

§Parameters
  • idx: this is the index in the specific type T array
Source

pub fn get_mut<T: 'static>(&mut self, idx: usize) -> Option<&mut T>

Get a mutable reference to a value in a TypePool

Source

pub fn len<T: 'static>(&self) -> Option<usize>

Source

pub fn types_count(&self) -> usize

The amount of types stored in pools

Source

pub fn types(&self) -> Vec<&TypeId>

The types stored in pools

Source

pub fn remove_type<T: 'static>(&mut self)

Remove all entries for a type

Source

pub fn remove_empty(&mut self)

Remove all types which do not contain any values

Source

pub fn shrink_to_fit(&mut self)

Shrink the array containing all the pools to fit

Auto Trait Implementations§

§

impl<H> Freeze for TypePools<H>
where H: Freeze,

§

impl<H = RandomState> !RefUnwindSafe for TypePools<H>

§

impl<H = RandomState> !Send for TypePools<H>

§

impl<H = RandomState> !Sync for TypePools<H>

§

impl<H> Unpin for TypePools<H>
where H: Unpin,

§

impl<H = RandomState> !UnwindSafe for TypePools<H>

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.