pub struct SymbolTable<K: Hash + Eq, V, S: BuildHasher = RandomState> { /* private fields */ }
Expand description

A simple, generic symbol table.

Behaves like a stack of HashMaps, where you can only insert symbols into the top map with insert. When a symbol is looked up with get, first the top map is checked, then the map under it, etc., with the first match found returned. This is implemented more efficiently using an IndexMap. get_full does the same, but returns the depth at which the symbol was found.

Implementations

Create a new, empty symbol table

Create a symbol table with a given capacity

Create a symbol table with a given hasher

Create a symbol table with a given capacity and hasher

Try to register a given symbol at the current depth. Fail if the symbol is already defined

Get the definition of a current symbol, along with its depth, if any

Get the definition of a current symbol, along with its depth, if any

Check whether a symbol has a definition

Mutably get the definition of a current symbol, along with its depth, if any

Jump to a given depth, removing obsolete definitions. Return the number of keys and definitions removed, as well as keys touched, if any.

Pop up to n levels of depth.

Reserve space for at least additional symbols in this symbol table

Get the capacity of this symbol table

Clear this symbol table, preserving it’s capacity

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
Get a mutable reference to the definition of a key in the top level of this symbol table
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
The value stored in this symbol table
Get the most recent definition of a key in this symbol table
Insert a key/value pair into this symbol table at the current level
Get the current depth of this symbol table
Try to get a mutable reference to the definition of a key in the top level of this symbol table Read more
Push a level onto this symbol table
Pop a level from this symbol table Read more
Whether this symbol table is empty
Whether this symbol table contains this key

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
Compare self to key and return true if they are equal.

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.