Expand description
An arena for interning strings (global, mutable, single thread only)
Note: works under the assumption of a single threaded, short-lived process, where memory starvation will not be an issue. It would need a hard reset if the same process does multiple conversions, and a different implementation if one needs a thread-local arena.
§Borrow safety
All arena access goes through with_arena_mut(), which acquires a mutable
borrow from RefCell on first call and caches the raw pointer in a
thread-local Cell. Re-entrant calls (e.g., pin() inside a with()
closure) reuse the cached pointer without touching RefCell, eliminating
borrow conflicts entirely. A RAII guard clears the pointer on scope exit
(including panics), so the invariant holds through unwinds.
Re-exports§
pub use data::SymHashMap;pub use data::SymStr;
Modules§
Functions§
- join
- len
- pin
- Assign a string into the arena, returning a unique symbol.
- pin_
char - pin_
static - Assign a static str into the arena, returning a unique symbol.
- reset
- Free every interned string on this thread, returning the arena to a fresh, empty state.
- to_
string - with
- Resolve a symbol and call the closure with a
&strreference. The closure may safely callpin()or any other arena function — re-entrant access reuses the cached borrow. - with2
- with3
- with_
many