Enum arenatree::Arena

source ·
pub enum Arena<'a, T: 'a> {
    Owned(Vec<Option<T>>),
    Borrowed(&'a mut Vec<Option<T>>),
}
Expand description

Arenas are efficient ways of storing trees: All nodes are actually on a flat surface, but have IDs to other nodes.

Variants§

§

Owned(Vec<Option<T>>)

§

Borrowed(&'a mut Vec<Option<T>>)

Implementations§

Create a new arena instance

Create a new arena instance that reuses an existing vector

Create a new arena reference that shares the inner vector. This reference will make the existing instance invalid for use while the reference is active.

Return the arena instance

Panics

Panics if this arena instance was created with Borrowed

Return a slice pointing to the inner arena representation

Return an iterator over the nodes in this arena

Place an element into the arena

Move out of an element in the arena. This will make following indexing calls on that index panic. This will not deallocate any space. This is due to the fact that all indexes need to stay the same. We could use a different data type instead of a tree to prevent this, but that instead means lookup will be slightly slower.

Get an iterator over all existing NodeIds in the arena.

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
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. 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.