Garbage-collected "interned" strings.
Interning is a process of making many equal things share the same underlying resource. This crate introduces two types that are powered by the Refuse garbage collector:
- [
RootString]: ARoot<String>-like type that ensures all instances of the same exact byte sequence refer to the same allocation. - [
RefString]: ARef<String>type that is a reference to a [RootString].
use CollectionGuard;
use ;
let a = from;
let a_again = from;
// Both a and a_again point to the same underlying storage.
assert_eq!;
// Comparing two RootStrings is cheap.
assert_eq!;
// a_ref can be used to gain a reference to a string,
// but only until the string is unreachable.
let a_ref = a.downgrade;
let mut guard = acquire;
assert_eq!;
drop;
drop;
guard.collect;
assert_eq!;