Module intern_all::instance

source ·
Expand description

The interner uses weak references and can be cleared with [sweep], but if you want to avoid using a global singleton, you can construct an instance too. Comparing tokens from different interners causes a panic.

use intern_all::instance::Interner;

// But you can also create an instance which has methods corresponding to
// all the above functions:
let int = Interner::new();
let k = int.i("foobar");

Structs

  • A collection of interners based on their type. Can be used to intern any object that implements ToOwned. Objects of the same type are stored together in a TypedInterner
  • An interner for any type that implements Borrow. Not many optimizations are employed and the interner uses the default allocator. This and the use of weak references means that a long-lived instance can be kept around with regular calls to TypedInterner::sweep.