#string-interning #string-cache #string #interning #symbol #constant-time #intern

no-std string-interner

Efficient string interner with minimal memory footprint and fast access to the underlying strings

25 releases (15 breaking)

new 0.18.0 Nov 12, 2024
0.17.0 May 1, 2024
0.16.0 May 1, 2024
0.15.0 Feb 7, 2024
0.3.3 Feb 27, 2017

#19 in Data structures

Download history 119662/week @ 2024-07-28 125129/week @ 2024-08-04 156148/week @ 2024-08-11 157677/week @ 2024-08-18 164980/week @ 2024-08-25 158925/week @ 2024-09-01 188237/week @ 2024-09-08 157114/week @ 2024-09-15 188080/week @ 2024-09-22 185782/week @ 2024-09-29 230779/week @ 2024-10-06 215687/week @ 2024-10-13 243506/week @ 2024-10-20 230551/week @ 2024-10-27 237740/week @ 2024-11-03 219670/week @ 2024-11-10

938,904 downloads per month
Used in 220 crates (41 directly)

MIT/Apache

66KB
1.5K SLoC

String Interner

Continuous Integration Test Coverage Documentation Crates.io
travisCI codecov docs crates

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.

Contributing

Testing

Test the project using

cargo test --release

Memory Allocation Tests

To further test memory consumption and allocations performed by the different string interner backends test the project as follows:

cargo test --release --features test-allocations -- --test-threads 1
  • The --features test-allocations enables the memory allocations tests.
  • The --test-thread 1 argument is required for the memory allocations tests since otherwise they interfere with each other causing them to randomly fail.
  • Use --nocapture to receive verbose output useful for debugging.

Profiling & Benchmarks

Benchmark the string interner and its various backends using

cargo bench

License

Licensed under either of

at your option.

Dual licence: badge badge

Contribution

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 below, without any additional terms or conditions.

Dependencies

~0.6–1MB
~16K SLoC