Struct string_interner::StringInterner[][src]

pub struct StringInterner<S, H = RandomState> where
    S: Symbol,
    H: BuildHasher
{ /* fields omitted */ }

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.

Methods

impl<S> StringInterner<S> where
    S: Symbol
[src]

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.

impl<S, H> StringInterner<S, H> where
    S: Symbol,
    H: BuildHasher
[src]

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.

Important traits for Iter<'a, S>

Returns an iterator over the interned strings.

Important traits for Values<'a, S>

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

Shrinks the capacity of the interner as much as possible.

Trait Implementations

impl<Sym, H> Serialize for StringInterner<Sym, H> where
    Sym: Symbol,
    H: BuildHasher
[src]

Serialize this value into the given Serde serializer. Read more

impl<'de, Sym, H> Deserialize<'de> for StringInterner<Sym, H> where
    Sym: Symbol,
    H: BuildHasher + Default
[src]

Deserialize this value from the given Serde deserializer. Read more

impl<S: Debug, H: Debug> Debug for StringInterner<S, H> where
    S: Symbol,
    H: BuildHasher
[src]

Formats the value using the given formatter. Read more

impl<S: Clone, H: Clone> Clone for StringInterner<S, H> where
    S: Symbol,
    H: BuildHasher
[src]

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

impl<S: Eq, H: Eq> Eq for StringInterner<S, H> where
    S: Symbol,
    H: BuildHasher
[src]

impl<S, H> PartialEq for StringInterner<S, H> where
    S: Symbol,
    H: BuildHasher
[src]

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

This method tests for !=.

impl Default for StringInterner<Sym, RandomState>
[src]

Returns the "default value" for a type. Read more

impl<S, H> Send for StringInterner<S, H> where
    S: Symbol + Send,
    H: BuildHasher
[src]

impl<S, H> Sync for StringInterner<S, H> where
    S: Symbol + Sync,
    H: BuildHasher
[src]

impl<T, S> FromIterator<T> for StringInterner<S> where
    S: Symbol,
    T: Into<String> + AsRef<str>, 
[src]

Creates a value from an iterator. Read more

impl<S, H> IntoIterator for StringInterner<S, H> where
    S: Symbol,
    H: BuildHasher
[src]

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