pub struct ArenaItems<C: Component> { /* private fields */ }
Expand description

A (mostly read-only) inner container holding Arena items. While Arena itself is unique (i.e. non-clonable) object, arena ‘items’ could be cloned.

Implementations§

An amount of memory required to hold one component.

This information can be useful for memory management fine-tuning.

An alignment of a cell, holding a component with all required metadata.

This information can be useful for memory management fine-tuning.

Returns a reference to the underlying allocator.

Returns the number of elements the arena can hold without reallocating.

Returns the number of elements in the arena.

This function has linear worst-case complexity.

Returns true iff the number of elements in the arena equals the maximum number of elements ever in the arena.

Because the arena capacity cannot be less than min_capacity, the returned false means there is space for at least one more item.

The returned value equals to self.len() == self.min_capacity(), but unlike len this function has constant complexity.

Returns true if the arena contains no elements.

This function has linear worst-case complexity.

Returns the maximum number of elements ever in the arena. The arena capacity cannot be less than min_capacity.

Arena min_capacity never decreases.

Examples
let mut arena = Arena::new();
assert_eq!(arena.items().min_capacity(), 0);
let id_1 = arena.insert(|id| (MyComponent { /* ... */ }, id));
assert_eq!(arena.items().min_capacity(), 1);
let id_2 = arena.insert(|id| (MyComponent { /* ... */ }, id));
assert_eq!(arena.items().min_capacity(), 2);
arena.remove(id_1);
assert_eq!(arena.items().min_capacity(), 2);
let id_3 = arena.insert(|id| (MyComponent { /* ... */ }, id));
assert_eq!(arena.items().min_capacity(), 2);
let id_4 = arena.insert(|id| (MyComponent { /* ... */ }, id));
assert_eq!(arena.items().min_capacity(), 3);

Reserves capacity for at least additional more elements. The collection may reserve more space to avoid frequent reallocations. After calling reserve, capacity will be greater than or equal to self.min_capacity() + additional. Does nothing if capacity is already sufficient.

Panics

Panics if the new capacity overflows usize.

Reserves the minimum capacity for exactly additional more elements. After calling reserve_exact, capacity will be greater than or equal to self.min_capacity() + additional. Does nothing if the capacity is already sufficient.

Note that the allocator may give the collection more space than it requests. Therefore, capacity can not be relied upon to be precisely minimal. Prefer reserve if future insertions are expected.

Panics

Panics if the new capacity overflows usize.

Shrinks the capacity of the arena with a lower bound.

The capacity will remain at least as large as both the min_capacity and the supplied value.

Shrinks the capacity of the vector as much as possible.

It will drop down as close as possible to the min_capacity but the allocator may still inform the arena that there is space for a few more elements.

Tries to reserve capacity for at least additional more elements. The collection may reserve more space to avoid frequent reallocations. After calling try_reserve, capacity will be greater than or equal to self.min_capacity() + additional. Does nothing if capacity is already sufficient.

Errors

If the capacity overflows, or the allocator reports a failure, then an error is returned.

Tries to reserve capacity for exactly additional more elements. The collection may reserve more space to avoid frequent reallocations. After calling try_reserve_exact, capacity will be greater than or equal to self.min_capacity() + additional. Does nothing if capacity is already sufficient.

Note that the allocator may give the collection more space than it requests. Therefore, capacity can not be relied upon to be precisely minimal. Prefer try_reserve if future insertions are expected.

Errors

If the capacity overflows, or the allocator reports a failure, then an error is returned.

Returns reference to the item occupying index place with its Id, or None if there is no such.

Panics

Panics if index is greater than or equal to min_capacity().

Returns mutable reference to the item occupying index place with its Id, or None if there is no such.

Panics

Panics if index is greater than or equal to min_capacity().

Returns Id of item occupying index place, or None if there is no such.

Panics

Panics if index is greater than or equal to min_capacity().

Returns reference to the item occupying index place, or None if there is no such.

Panics

Panics if index is greater than or equal to min_capacity().

Returns mutable reference to the item occupying index place, or None if there is no such.

Panics

Panics if index is greater than or equal to min_capacity().

Returns an iterator over all item ids.

Returns an iterator over all items.

Returns a mutable iterator over all items.

Returns an iterator over all items combined with their ids.

Returns a mutable iterator over all items combined with their ids.

Transforms the container into an iterator over all items ids.

Transforms the container into an iterator over all items.

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
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. Read more
The type of the elements being iterated over.
Which kind of iterator are we turning this into?
Creates an iterator from a value. 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.