pub struct SlabAlloc<T, IndexType = u32, IdType = u32> {
    data: Vec<Element<IdType, T>>,
    free_indices: Vec<IndexType>,
    len: usize,
}
Expand description

Container which efficiently allocates space for its elements.

Fields

data: Vec<Element<IdType, T>>free_indices: Vec<IndexType>len: usize

Number of elements currently in the map.

Implementations

Create an empty container.

Access an element.

Access an element.

Insert an element and return the index of it.

Panics

Panics when the amount of indices is exhausted. This happens when there are already IndexType::max_value() elements in the container.

Allocate space to hold n elements.

Remove an element.

Reclaim as much space as possible.

Drop all data.

Iterate over all key-value pairs.

Iterate over all key-value pairs.

Iterate over all values in the map.

Iterate over all mutable values in the map.

Iterate over all keys in the map.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.