#string-interning #hash #symbols #hash-cache #cache

inturn

Efficient, performant, thread-safe bytes/string interning

3 releases

Uses new Rust 2024

0.1.2 Aug 23, 2025
0.1.1 Jun 17, 2025
0.1.0 Jun 6, 2025

#368 in Caching

Download history 9132/week @ 2026-01-16 9447/week @ 2026-01-23 9823/week @ 2026-01-30 12235/week @ 2026-02-06 13613/week @ 2026-02-13 10101/week @ 2026-02-20 7344/week @ 2026-02-27 12443/week @ 2026-03-06 11264/week @ 2026-03-13 9558/week @ 2026-03-20 11815/week @ 2026-03-27 13404/week @ 2026-04-03 11811/week @ 2026-04-10 14068/week @ 2026-04-17 11724/week @ 2026-04-24 9382/week @ 2026-05-01

49,844 downloads per month
Used in 16 crates (2 directly)

MIT/Apache

28KB
460 lines

inturn

github crates.io docs.rs build status

Efficient, performant, thread-safe bytes/string interning.

This crate was designed to have a lock-free mapping of symbols back to their original string.

It currently uses dashmap for deduplicating strings, and a lock-free stack to map the string index (symbol) back to the string bytes.

It supports interning any &str/&[u8] by allocating it internally in an efficient arena when encountered for the first time, or &'static str/&'static [u8] without allocation.

A *_mut variant of each API is provided which side-step any locks, for e.g. initializing the interner with a static set of strings to pre-intern.

Examples

Basic str interning (the same API is available with BytesInterner for [u8]):

use inturn::Interner;

let interner = Interner::new();
let hello = interner.intern("hello");
assert_eq!(hello.get(), 0);
assert_eq!(interner.resolve(hello), "hello");

let world = interner.intern("world");
assert_eq!(world.get(), 1);
assert_eq!(interner.resolve(world), "world");

let hello2 = interner.intern("hello");
assert_eq!(hello, hello2);

assert_eq!(interner.len(), 2);

Dependencies

~2MB
~28K SLoC