Struct arc_string_interner::StringInterner[][src]

pub struct StringInterner<S, H, const N: usize> where
    S: Symbol,
    H: BuildHasher
{ /* fields omitted */ }
Expand description

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.

Implementations

Creates a new empty StringInterner.

Creates a new StringInterner with the given initial capacity.

Index in arena from Sym

Shard index from Sym

Creates a new empty StringInterner with the given hasher.

Creates a new empty StringInterner with the given initial capacity and the given hasher.

Interns the given value.

Returns a symbol to access it within this interner.

This either copies the contents of the string (e.g. for str) or moves them into this interner (e.g. for String).

Returns the string slice associated with the given symbol if available, otherwise returns None.

Returns the string associated with the given symbol.

Note

This does not check whether the given symbol has an associated string for the given string interner instance.

Safety

This will result in undefined behaviour if the given symbol had no associated string for this interner instance.

Returns the symbol associated with the given string for this interner if existent, otherwise returns None.

Returns the number of uniquely interned strings within this interner.

Returns true if the string interner holds no elements.

Shrinks the capacity of the interner as much as possible.

Clears the StringInterner

Trait Implementations

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.