#string-interning #string #interning #symbol #intern #str

no-std string-interner

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

22 releases (12 breaking)

0.15.0 Feb 7, 2024
0.14.0 Oct 27, 2021
0.13.0 Aug 25, 2021
0.12.2 Jan 11, 2021
0.3.3 Feb 27, 2017

#47 in Data structures

Download history 28817/week @ 2024-01-01 42406/week @ 2024-01-08 48804/week @ 2024-01-15 47474/week @ 2024-01-22 45293/week @ 2024-01-29 52822/week @ 2024-02-05 54248/week @ 2024-02-12 56115/week @ 2024-02-19 81253/week @ 2024-02-26 65311/week @ 2024-03-04 54914/week @ 2024-03-11 51343/week @ 2024-03-18 61720/week @ 2024-03-25 67781/week @ 2024-04-01 72853/week @ 2024-04-08 75427/week @ 2024-04-15

278,588 downloads per month
Used in 121 crates (28 directly)

MIT/Apache

68KB
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

~1.2–1.6MB
~23K SLoC