Struct string_interner::StringInterner [] [src]

pub struct StringInterner<Sym> where
    Sym: Symbol
{ /* 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.

Used instead of Deriving from Default to not make internals depend on it.

Creates a new StringInterner with a given capacity.

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

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

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

Formats the value using the given formatter.

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

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

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

This method tests for !=.

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

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

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

impl<Sym> IntoIterator for StringInterner<Sym> where
    Sym: Symbol
[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