| Continuous Integration | Test Coverage | Documentation | Crates.io |
|:----------------------:|:--------------------:|:----------------:|:--------------------:|
| |
|
|
|
A data structure to cache strings efficiently, with minimal memory footprint and the ability to assicate the interned strings with unique symbols. These symbols allow for constant time comparisons and look-ups to the underlying interned string contents. Also, iterating through the interned strings is cache efficient.
M
and a vector V
is used.V
stores the contents of interned strings while M
has internal references into the string of V
to avoid duplicates.V
stores the strings with an indirection to avoid iterator invalidation.Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
0.10.1 (not released, yet)
&'static str
using get_or_intern_static
API.
SymbolU16
and SymbolU32
that instantiating them with values
greater or equal to u16::MAX
or u32::MAX
respectively caused them to
panic instead of returning None
.
0.10.0
Special thanks to CAD97 who motivated me to craft this release through their blog post "String interners in Rust".
Implement pluggable backends for StringInterner
.
Uses the new BucketBackend
by default which results in significant
performance boosts and lower memory consumption as well as fewer overall
memory allocations.
This makes it possible for dependencies to alter the behavior of internment.
The string-interner
crate comes with 2 predefined backends:
SimpleBackend
: Which is how the StringInterner
of previous versions
worked by default. It performs one allocation per interned string.BucketBackend
: Tries to minimize memory allocations and packs
interned strings densely. This is the new default behavior for this crate.reserve
capacity
iter
module
StringInterer
's interned strings
and their symbols is still possible if the used backend supports
iteration.resolve_unchecked
: Has no replacement, yet but might be reintroduced
in future versions again.shrink_to_fit
: The API design was never really a good fit for interners.0.9.0
Ord
trait bound from Symbol
trait
Symbol::from_usize(usize) -> Self
to Symbol::try_from_usize(usize) -> Option<Self>
DefaultSymbol::try_from_usize
iter
sub modulesymbol
sub moduleSymbolU16
: 16-bit wide symbolSymbolU32
: 32-bit wide symbol (default)SymbolUsize
: same size as usize
0.8.0
no_std
environments
hashbrown
crate feature together with no_std
Sym
to DefaultSymbol
IntoIterator
impl for &StringInterner
#[inline]
annotations which improve performance for queriesPin
self-referentials now)0.7.1
StringInterner::clone()
std::iter::Extend
for StringInterner
Sym::from_usize
now avoids using unsafe
codeFromIterator
impl of StringInterner
Thanks YOSHIOKA Takuma for implementing this release.
0.7.0
Symbol
for types that are From<usize>
and Into<usize>
StringInterner::clear
API since its usage breaks invariantsStringInterner::{capacity, reserve}
APIsSym
that is a thin wrapper around NonZeroU32
(idea by koute)DefaultStringInterner
a type alias for the new StringInterner<Sym>
FromIterator
impl to StringInterner<S: Sym>
html_root_url
to crate rootThanks matklad for suggestions and impulses
0.6.3
StringInterner
's Send
impl didn't respect its generic HashBuilder
parameter. Fixes GitHub issue #4.0.6.2
shrink_to_fit
public method to StringInterner
- (by artemshein)0.6.1
str
) was broken due to dangling pointers (Thanks to artemshein for fixing it!)0.6.0
PartialEq
implementation for StringInterner
StringInterner
generic over BuildHasher
to allow for custom hashers0.5.0
IntoIterator
trait implementation for StringInterner
0.4.0
Unsigned
for Symbol
0.3.3
Send
and Sync
to InternalStrRef
to make StringInterner
itself Send
and Sync