String Pools / Strings Interning
Features
- quick
Deref<str>implementation - one pointer resolution, one comparison, and one pointer increment - thin [
PoolStr] type - a pointer - The pool is deallocated only when every object referencing it have been dropped.
- no_std, but
allocis required
Example: Initiating a fetch from github
# use ;
// no need for mutability, the pool uses atomic operations
let pool = new;
// use Pool::intern(&self, &str) to insert a string slice into the pool
// if the string was already present, that PoolStr will be reused.
let pool_string = pool.intern;
// you can obtain a &str with the Deref implementation
assert_eq!;
// Hash, Eq, Debug, Display are implemented as well.
// you can use Pool::find(&self, &str) to check if the pool contains a string
assert_eq!;
// the empty string doesn't rely on a pool, it's always there
assert_eq!;
Internal Memory Structure (Example)
