Skip to main content

Module interning

Module interning 

Source
Expand description

§Interning System

This module provides a minimal system for global interning of values in Rust. Interning allows you to deduplicate equal values and replace them with cheap, copyable handles (Interned<T>) that support O(1) equality, hashing, and compact storage.

§Core Concepts

§Safety Note

The .get() method on Interned<T> returns a &'static T using an internal transmute, assuming the backing storage (interning table) never remove items from its table. This is guaranteed by the implementation of InterningTable.

Structs§

ExplicitClosure
A tiny, FnOnce-compatible wrapper used to initialize a LazyLock with a captured value.
Interned
A statically interned value of type T.
InterningTable
An interning table storing unique values of T and assigning them stable indices.

Traits§

Internable
Types that have a single, process‑global interning table.

Type Aliases§

LazyLockNewWithValue
A type alias representing a lazily initialized Mutex<InterningTable<T>> backed by a fixed-size array initializer.