Struct string_interner::StringInterner [−][src]
pub struct StringInterner<S = DefaultSymbol, B = DefaultBackend<S>, H = DefaultHashBuilder> where
S: Symbol,
H: BuildHasher, { /* fields omitted */ }
Expand description
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
string
type tosymbol
type.
- This maps from
StringInterner::resolve
: To resolve your already interned strings.- This maps from
symbol
type tostring
type.
- This maps from
Implementations
impl<S, B, H> StringInterner<S, B, H> where
S: Symbol,
B: Backend<S>,
H: BuildHasher + Default,
impl<S, B, H> StringInterner<S, B, H> where
S: Symbol,
B: Backend<S>,
H: BuildHasher + Default,
Creates a new StringInterner
with the given initial capacity.
Creates a new empty StringInterner
with the given hasher.
Creates a new empty StringInterner
with the given initial capacity and the given hasher.
Returns the symbol for the given string if any.
Can be used to query if a string has already been interned without interning.
Interns the given string.
Returns a symbol for resolution into the original string.
Panics
If the interner already interns the maximum number of strings possible by the chosen symbol type.
Interns the given 'static
string.
Returns a symbol for resolution into the original string.
Note
This is more efficient than StringInterner::get_or_intern
since it might
avoid some memory allocations if the backends supports this.
Panics
If the interner already interns the maximum number of strings possible by the chosen symbol type.
Shrink backend capacity to fit the interned strings exactly.
Trait Implementations
impl<S, B, H> Clone for StringInterner<S, B, H> where
S: Symbol,
B: Backend<S> + Clone,
H: BuildHasher + Clone,
impl<S, B, H> Clone for StringInterner<S, B, H> where
S: Symbol,
B: Backend<S> + Clone,
H: BuildHasher + Clone,
impl<S, B, H> Debug for StringInterner<S, B, H> where
S: Symbol + Debug,
B: Backend<S> + Debug,
H: BuildHasher,
impl<S, B, H> Debug for StringInterner<S, B, H> where
S: Symbol + Debug,
B: Backend<S> + Debug,
H: BuildHasher,
impl<'de, S, B, H> Deserialize<'de> for StringInterner<S, B, H> where
S: Symbol,
B: Backend<S>,
H: BuildHasher + Default,
impl<'de, S, B, H> Deserialize<'de> for StringInterner<S, B, H> where
S: Symbol,
B: Backend<S>,
H: BuildHasher + Default,
fn deserialize<D>(deserializer: D) -> Result<StringInterner<S, B, H>, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<StringInterner<S, B, H>, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl<S, B, H, T> Extend<T> for StringInterner<S, B, H> where
S: Symbol,
B: Backend<S>,
H: BuildHasher,
T: AsRef<str>,
impl<S, B, H, T> Extend<T> for StringInterner<S, B, H> where
S: Symbol,
B: Backend<S>,
H: BuildHasher,
T: AsRef<str>,
Extends a collection with the contents of an iterator. Read more
extend_one
)Extends a collection with exactly one element.
extend_one
)Reserves capacity in a collection for the given number of additional elements. Read more
impl<S, B, H, T> FromIterator<T> for StringInterner<S, B, H> where
S: Symbol,
B: Backend<S>,
H: BuildHasher + Default,
T: AsRef<str>,
impl<S, B, H, T> FromIterator<T> for StringInterner<S, B, H> where
S: Symbol,
B: Backend<S>,
H: BuildHasher + Default,
T: AsRef<str>,
Creates a value from an iterator. Read more
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,
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,
impl<S, B, H> PartialEq<StringInterner<S, B, H>> for StringInterner<S, B, H> where
S: Symbol,
B: Backend<S> + PartialEq,
H: BuildHasher,
impl<S, B, H> PartialEq<StringInterner<S, B, H>> for StringInterner<S, B, H> where
S: Symbol,
B: Backend<S> + PartialEq,
H: BuildHasher,
impl<S, B, H> Serialize for StringInterner<S, B, H> where
S: Symbol,
B: Backend<S>,
for<'a> &'a B: IntoIterator<Item = (S, &'a str)>,
H: BuildHasher,
impl<S, B, H> Serialize for StringInterner<S, B, H> where
S: Symbol,
B: Backend<S>,
for<'a> &'a B: IntoIterator<Item = (S, &'a str)>,
H: BuildHasher,
impl<S, B, H> Eq for StringInterner<S, B, H> where
S: Symbol,
B: Backend<S> + Eq,
H: BuildHasher,
Auto Trait Implementations
impl<S, B, H> RefUnwindSafe for StringInterner<S, B, H> where
B: RefUnwindSafe,
H: RefUnwindSafe,
S: RefUnwindSafe,
impl<S, B, H> Send for StringInterner<S, B, H> where
B: Send,
H: Send,
S: Send,
impl<S, B, H> Sync for StringInterner<S, B, H> where
B: Sync,
H: Sync,
S: Sync,
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
Mutably borrows from an owned value. Read more