Skip to main content

Module intern

Module intern 

Source
Expand description

String interner that hands out compact Symbol handles.

Interner deduplicates owned String storage: every call to Interner::intern returns the same Symbol for the same input. Equality and hashing operate on the four-byte symbol rather than the underlying bytes, which is the win when the same identifier appears thousands of times across a workload.

§Cost summary

  • intern: O(log n) on a first sight; O(log n) on a repeated sight.
  • resolve: O(1).
  • len / is_empty: O(1).

The implementation uses an ordered map for the de-duplication index so that the crate stays no_std-compatible without pulling in hashbrown. Hash-backed lookup is planned for the 0.5 milestone.

Structs§

Interner
String interner. See the module-level docs.
Iter
Iterator over (Symbol, &str) pairs returned by Interner::iter.
Symbol
Compact handle returned by Interner::intern.