[−][src]Struct string_interner::StringInterner
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:
StringInterner::get_or_intern: To intern a new string.- This maps from
stringtype tosymboltype.
- This maps from
StringInterner::resolve: To resolve your already interned strings.- This maps from
symboltype tostringtype.
- This maps from
Implementations
impl<S, B, H> StringInterner<S, B, H> where
S: Symbol,
B: Backend<S>,
H: BuildHasher + Default, [src]
S: Symbol,
B: Backend<S>,
H: BuildHasher + Default,
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]
S: Symbol,
B: Backend<S>,
H: BuildHasher,
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]
T: AsRef<str>,
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]
T: AsRef<str>,
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]
S: Symbol,
B: Backend<S> + Clone,
&'a B: IntoIterator<Item = (S, &'a str)>,
H: BuildHasher + Default,
fn clone(&self) -> Self[src]
fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<S: Debug, B: Debug, H: Debug> Debug for StringInterner<S, B, H> where
S: Symbol,
B: Backend<S>,
H: BuildHasher, [src]
S: Symbol,
B: Backend<S>,
H: BuildHasher,
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]
S: Symbol,
B: Backend<S>,
H: BuildHasher + Default,
fn deserialize<D>(deserializer: D) -> Result<StringInterner<S, B, H>, D::Error> where
D: Deserializer<'de>, [src]
D: Deserializer<'de>,
impl<S, B, H> Eq for StringInterner<S, B, H> where
S: Symbol,
B: Backend<S> + Eq,
H: BuildHasher, [src]
S: Symbol,
B: Backend<S> + Eq,
H: BuildHasher,
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]
S: Symbol,
B: Backend<S>,
H: BuildHasher,
T: AsRef<str>,
fn extend<I>(&mut self, iter: I) where
I: IntoIterator<Item = T>, [src]
I: IntoIterator<Item = T>,
fn extend_one(&mut self, item: A)[src]
fn extend_reserve(&mut self, additional: usize)[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]
S: Symbol,
B: Backend<S>,
H: BuildHasher + Default,
T: AsRef<str>,
fn from_iter<I>(iter: I) -> Self where
I: IntoIterator<Item = T>, [src]
I: IntoIterator<Item = T>,
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]
S: Symbol,
B: Backend<S>,
&'a B: IntoIterator<Item = (S, &'a str)>,
H: BuildHasher,
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?
fn into_iter(self) -> Self::IntoIter[src]
impl<S, B, H> PartialEq<StringInterner<S, B, H>> for StringInterner<S, B, H> where
S: Symbol,
B: Backend<S> + PartialEq,
H: BuildHasher, [src]
S: Symbol,
B: Backend<S> + PartialEq,
H: BuildHasher,
impl<S, B, H> Send for StringInterner<S, B, H> where
S: Symbol + Send,
B: Backend<S> + Send,
H: BuildHasher, [src]
S: Symbol + Send,
B: Backend<S> + Send,
H: BuildHasher,
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]
S: Symbol,
B: Backend<S>,
&'a B: IntoIterator<Item = (S, &'a str)>,
H: BuildHasher,
impl<S, B, H> Sync for StringInterner<S, B, H> where
S: Symbol + Sync,
B: Backend<S> + Sync,
H: BuildHasher, [src]
S: Symbol + Sync,
B: Backend<S> + Sync,
H: BuildHasher,
Auto Trait Implementations
impl<S, B, H> RefUnwindSafe for StringInterner<S, B, H> where
B: RefUnwindSafe,
H: RefUnwindSafe,
S: RefUnwindSafe,
B: RefUnwindSafe,
H: RefUnwindSafe,
S: RefUnwindSafe,
impl<S, B, H> Unpin for StringInterner<S, B, H> where
B: Unpin,
H: Unpin,
S: Unpin,
B: Unpin,
H: Unpin,
S: Unpin,
impl<S, B, H> UnwindSafe for StringInterner<S, B, H> where
B: UnwindSafe,
H: UnwindSafe,
S: UnwindSafe,
B: UnwindSafe,
H: UnwindSafe,
S: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T[src]
fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,