[][src]Crate refcount_interner

A simple reference-counted interning library for strings, slices, and other data.

This crate provides two kinds of owned interners that store the interned data in the reference-counted types Rc<T> or Arc<T>. When the shrink_to_fit() method is called on the interner, or when the interner is dropped, unused interned objects are deallocated.

The two kinds of interners provided by this crate are RcInterner and ArcInterner, returning Rc<T> and Arc<T> objects respectively.


use std::rc::Rc;
use refcount_interner::RcInterner;

let mut interner = RcInterner::new();

let hello = interner.intern_str("hello");
let world = interner.intern_str("world");

assert!(Rc::ptr_eq(&hello, &interner.intern_str("hello")));



An interner returning atomically reference-counted pointers to the interned data


An interner returning reference-counted pointers to the interned data