7 releases
new 0.1.0-rc.5 | Mar 20, 2025 |
---|---|
0.1.0-rc.3 | Mar 16, 2025 |
0.1.0-rc.2 | Mar 15, 2025 |
0.1.0-alpha.2 | Feb 10, 2025 |
#1343 in Rust patterns
574 downloads per month
36KB
682 lines
paracord
A fast, simple, multi-threaded string interning library.
lib.rs
:
ParaCord
is a lightweight, thread-safe, memory efficient string interer.
When calling ParaCord::get_or_intern
, a [Key
] is returned. This [Key
] is guaranteed to be unique if the input string is unique,
and is guaranteed to be the same if the input string is the same. [Key
] is 32bits, and has a niche value which allows Option<Key>
to
also be 32bits.
If you don't want to intern the string, but check for it's existence, you can use ParaCord::get
, which returns None
if not
present.
[Key
]s can be exchanged back into strings using ParaCord::resolve
. It's important to keep in mind that this might panic
or return nonsense results if given a key returned by some other ParaCord
instance.
This string interner is not garbage collected, so strings that are allocated in the interner are not released
until the ParaCord
instance is dropped.
Dependencies
~1–24MB
~319K SLoC