Expand description
The Arena, UniqueArena, and Handle types.
To improve translator performance and reduce memory usage, most structures are
stored in an Arena. An Arena<T> stores a series of T values, indexed by
Handle<T> values, which are just wrappers around integer indexes.
For example, a Functionโs expressions are stored in an Arena<Expression>,
and compound expressions refer to their sub-expressions via Handle<Expression>
values.
A UniqueArena is just like an Arena, except that it stores only a single
instance of each value. The value type must implement Eq and Hash. Like an
Arena, inserting a value into a UniqueArena returns a Handle which can be
used to efficiently access the value, without a hash lookup. Inserting a value
multiple times returns the same Handle.
If the span feature is enabled, both Arena and UniqueArena can associate a
source code span with each element.
Re-exportsยง
pub use handle::BadHandle;pub use handle::Handle;pub use range::BadRangeError;pub use range::Range;pub use unique_arena::UniqueArena;
Modulesยง
- handle ๐
- Well-typed indices into
Arenas andUniqueArenas. - handle_
set ๐ - The
HandleSettype and associated definitions. - handlevec ๐
- The
HandleVectype and associated definitions. - range ๐
- Well-typed ranges of
Arenas. - unique_
arena ๐ - The
UniqueArenatype and supporting definitions.
Structsยง
- Arena
- An arena holding some kind of component (e.g., type, constant, instruction, etc.) that can be referenced.