Struct string_interner::StringInterner[][src]

pub struct StringInterner<S = DefaultSymbol, B = DefaultBackend<S>, H = DefaultHashBuilder> where
    S: Symbol,
    H: BuildHasher
{ /* fields omitted */ }
Expand description

Data structure to intern and resolve strings.

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.

The following API covers the main functionality:

Implementations

Creates a new empty StringInterner.

Creates a new StringInterner with the given initial capacity.

Creates a new empty StringInterner with the given hasher.

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

Returns the number of strings interned by the interner.

Returns true if the string interner has no interned strings.

Returns the symbol for the given string if any.

Can be used to query if a string has already been interned without interning.

Interns the given string.

Returns a symbol for resolution into the original string.

Panics

If the interner already interns the maximum number of strings possible by the chosen symbol type.

Interns the given 'static string.

Returns a symbol for resolution into the original string.

Note

This is more efficient than StringInterner::get_or_intern since it might avoid some memory allocations if the backends supports this.

Panics

If the interner already interns the maximum number of strings possible by the chosen symbol type.

Shrink backend capacity to fit the interned strings exactly.

Returns the string for the given symbol if any.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Deserialize this value from the given Serde deserializer. Read more

Extends a collection with the contents of an iterator. Read more

🔬 This is a nightly-only experimental API. (extend_one)

Extends a collection with exactly one element.

🔬 This is a nightly-only experimental API. (extend_one)

Reserves capacity in a collection for the given number of additional elements. Read more

Creates a value from an iterator. Read more

The type of the elements being iterated over.

Which kind of iterator are we turning this into?

Creates an iterator from a value. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. 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 resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

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.