[][src]Struct string_interner::StringInterner

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

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

impl<S, B, H> StringInterner<S, B, H> where
    S: Symbol,
    B: Backend<S>,
    H: BuildHasher + Default
[src]

pub fn new() -> Self[src]

Creates a new empty StringInterner.

pub fn with_capacity(cap: usize) -> Self[src]

Creates a new StringInterner with the given initial capacity.

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

pub fn with_hasher(hash_builder: H) -> Self[src]

Creates a new empty StringInterner with the given hasher.

pub fn with_capacity_and_hasher(cap: usize, hash_builder: H) -> Self[src]

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

pub fn len(&self) -> usize[src]

Returns the number of strings interned by the interner.

pub fn is_empty(&self) -> bool[src]

Returns true if the string interner has no interned strings.

pub fn get<T>(&self, string: T) -> Option<S> where
    T: AsRef<str>, 
[src]

Returns the symbol for the given string if any.

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

pub fn get_or_intern<T>(&mut self, string: T) -> S where
    T: AsRef<str>, 
[src]

Interns the given string.

Returns a symbol for resolution into the original string.

pub fn resolve(&self, symbol: S) -> Option<&str>[src]

Returns the string for the given symbol if any.

Trait Implementations

impl<S, B, H> Clone for StringInterner<S, B, H> where
    S: Symbol,
    B: Backend<S> + Clone,
    &'a B: IntoIterator<Item = (S, &'a str)>,
    H: BuildHasher + Default
[src]

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

impl Default for StringInterner<DefaultSymbol, DefaultBackend, DefaultHashBuilder>[src]

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

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

impl<'a, S, B, H, T> Extend<T> for StringInterner<S, B, H> where
    S: Symbol,
    B: Backend<S>,
    H: BuildHasher,
    T: AsRef<str>, 
[src]

impl<'a, S, B, H, T> FromIterator<T> for StringInterner<S, B, H> where
    S: Symbol,
    B: Backend<S>,
    H: BuildHasher + Default,
    T: AsRef<str>, 
[src]

impl<'a, S, B, H> IntoIterator for &'a StringInterner<S, B, H> where
    S: Symbol,
    B: Backend<S>,
    &'a B: IntoIterator<Item = (S, &'a str)>,
    H: BuildHasher
[src]

type Item = (S, &'a str)

The type of the elements being iterated over.

type IntoIter = <&'a B as IntoIterator>::IntoIter

Which kind of iterator are we turning this into?

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

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

impl<S, B, H> Serialize for StringInterner<S, B, H> where
    S: Symbol,
    B: Backend<S>,
    &'a B: IntoIterator<Item = (S, &'a str)>,
    H: BuildHasher
[src]

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

Auto Trait Implementations

impl<S, B, H> RefUnwindSafe for StringInterner<S, B, H> where
    B: RefUnwindSafe,
    H: RefUnwindSafe,
    S: RefUnwindSafe

impl<S, B, H> Unpin for StringInterner<S, B, H> where
    B: Unpin,
    H: Unpin,
    S: Unpin

impl<S, B, H> UnwindSafe for StringInterner<S, B, H> where
    B: UnwindSafe,
    H: UnwindSafe,
    S: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.