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: expected O(1) on first sight; expected O(1) on repeated sight.
  • resolve: O(1).
  • lookup / contains: expected O(1).
  • len / is_empty: O(1).

The implementation uses hashbrown::HashMap for the de-duplication index, keeping intern / lookup at expected O(1) while still compiling under no_std.

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.