Library for interning based on stdlib Arc
The design of the hash-based half is taken from the arc-interner
crate, with the addition of another half based on BTreeMap.
Local benchmarks have shown that hashing is faster for objects below 1kB while tree traversal
and comparisons are faster above 1kB (very roughly and broadly speaking).
The main functions exist in three variants:
intern_hashand friends for when you want to use hashing (or have noOrdinstance at hand)intern_treeand friends for when you want to use tree map (or have noHashinstance at hand)internand friends to automatically choose based on object size
Within each of these classes, four function exist to ingest data in various forms:
use Arc;
use ;
// for sized types
let a1: = intern;
// for unsized non-owned types
let a2: = intern_unsized;
// for unsized owned types
let a3: = intern_boxed;
// for types with shared ownership
let a4: = intern_arc;
Introspection
This library offers some utilities for checking how well it works for a given use-case:
use Arc;
use ;
println!;
let = types_interned;
println!;
;
All function exist also with tree suffix instead of hash.