Struct string_interner::StringInterner [] [src]

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

Provides a bidirectional mapping between String stored within the interner and indices. The main purpose is to store every unique String only once and make it possible to reference it via lightweight indices.

Compilers often use this for implementing a symbol table.

The main goal of this StringInterner is to store String with as low memory overhead as possible.

Methods

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

Creates a new empty StringInterner.

Creates a new StringInterner with the given initial capacity.

impl<Sym, H> StringInterner<Sym, H> where
    Sym: 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 a string slice to the string identified by the given symbol if available. Else, None is returned.

Returns a string slice to the string identified by the given symbol, without doing bounds checking. So use it very carefully!

Returns the given string's symbol for this interner if existent.

Returns the number of uniquely stored Strings interned within this interner.

Returns true if the string interner internes no elements.

Returns an iterator over the interned strings.

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

Removes all interned Strings from this interner.

This invalides all Symbol entities instantiated by it so far.

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<Sym> Send for StringInterner<Sym> where
    Sym: Symbol + Send
[src]

impl<Sym> Sync for StringInterner<Sym> where
    Sym: Symbol + Sync
[src]

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

Formats the value using the given formatter.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

impl<Sym, H> PartialEq for StringInterner<Sym, H> where
    Sym: 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<usize, RandomState>
[src]

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

impl<Sym, H> IntoIterator for StringInterner<Sym, H> where
    Sym: 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