pub struct AtomTable { /* private fields */ }Expand description
Concurrent intern table for atom strings.
The table stores atoms in both directions. Strings are leaked when first
interned because runtime atoms are never freed in this design, which lets
resolve return a borrowed &str without tying it to a map guard.
Implementations§
Source§impl AtomTable
impl AtomTable
Sourcepub fn new() -> Self
pub fn new() -> Self
Create an atom table with the common atoms at stable indices.
There is deliberately no constructor that omits them. Every Atom::*
constant is an index into this table, so a table that seats nothing
hands those same indices to whatever it interns first, and Atom::NIL
then resolves to a real but unrelated name rather than to nothing. That
is worse than a missing name, because a wrong name from the right
domain survives the sanity check a missing one would fail: the telemetry
span that exposed this reported code.module = "put_chars".
Sourcepub fn with_common_atoms() -> Self
pub fn with_common_atoms() -> Self
Create an atom table with the common atoms at stable indices.
Equivalent to AtomTable::new, which seats them unconditionally.
Retained because the name states the invariant at the call site.
Sourcepub fn intern(&self, name: &str) -> Atom
pub fn intern(&self, name: &str) -> Atom
Intern name, returning its existing or newly assigned atom.