Struct arc_string_interner::StringInterner[][src]

pub struct StringInterner<S, H = RandomState> 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.

Returns the number of elements the StringInterner can hold without reallocating.

Reserves capacity for at least additional more elements to be interned into self.

The collection may reserve more space to avoid frequent allocations. After calling reserve, capacity will be greater than or equal to self.len() + additional. Does nothing if capacity is already sufficient.

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.

Returns an iterator over the interned strings.

Returns an iterator over all intern indices and their associated strings.

Shrinks the capacity of the interner as much as possible.

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.