[][src]Crate arc_string_interner

Caches strings efficiently, with minimal memory footprint and associates them with unique symbols. These symbols allow constant time comparisons and look-ups to the underlying interned strings.

Example: Interning & Symbols

use arc_string_interner::StringInterner;

let mut interner = StringInterner::default();
let sym0 = interner.get_or_intern("Elephant");
let sym1 = interner.get_or_intern("Tiger");
let sym2 = interner.get_or_intern("Horse");
let sym3 = interner.get_or_intern("Tiger");
assert_ne!(sym0, sym1);
assert_ne!(sym0, sym2);
assert_ne!(sym1, sym2);
assert_eq!(sym1, sym3); // same!

Example: Creation by FromIterator

let interner = vec!["Elephant", "Tiger", "Horse", "Tiger"]
	.into_iter()
	.collect::<DefaultStringInterner>();

Example: Look-up

let mut interner = StringInterner::default();
let sym = interner.get_or_intern("Banana");
assert_eq!(interner.resolve(sym).map(ToString::to_string), Some("Banana".to_owned()));

Example: Iteration

let interner = vec!["Earth", "Water", "Fire", "Air"]
	.into_iter()
	.collect::<DefaultStringInterner>();
for (sym, str) in interner {
	// iteration code here!
}

Structs

IntoIter

Iterator over the pairs of associated symbol and strings.

Iter

Iterator over the pairs of associated symbols and interned strings for a StringInterner.

StringInterner

Caches strings efficiently, with minimal memory footprint and associates them with unique symbols. These symbols allow constant time comparisons and look-ups to the underlying interned strings.

Sym

Symbol type used by the DefaultStringInterner.

Values

Iterator over the interned strings of a StringInterner.

Traits

Symbol

Types implementing this trait are able to act as symbols for string interners.

Type Definitions

DefaultStringInterner

StringInterner that uses Sym as its underlying symbol type.