Internable

Trait Internable 

Source
pub trait Internable:
    Sized
    + Hash
    + Eq
    + Clone
    + Send
    + 'static {
    // Required method
    fn interning_table() -> &'static Mutex<InterningTable<Self>>;

    // Provided method
    fn intern(&self) -> Interned<Self> { ... }
}
Expand description

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

Implement this for your type to opt in to interning: provide a static (usually a LazyLock<Mutex<InterningTable<Self>>>) and return a reference to it.

Required Methods§

Source

fn interning_table() -> &'static Mutex<InterningTable<Self>>

Returns the global interning table for Self.

Provided Methods§

Source

fn intern(&self) -> Interned<Self>

Interns a value and returns its compact handle.

If an equal value has been interned before, this returns the existing handle; otherwise it inserts the value into the global table.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§