#value #string #str-id

str_id

Interns str slices, giving you back an ID value

2 releases

Uses new Rust 2024

0.1.1 Apr 14, 2025
0.1.0 Apr 13, 2025

#202 in Caching

Download history 212/week @ 2025-04-09 64/week @ 2025-04-16 10/week @ 2025-04-23

286 downloads per month
Used in 2 crates

Zlib OR Apache-2.0 OR MIT

7KB
130 lines

str_id

Interns str slices into ID values


lib.rs:

Interns str slices, giving you back an ID value.

The ID value is a newtyped [NonZeroUsize]. You get approximately the same benefits as using Box<Str>, but when the same str is used in multiple locations they'll resolve to the same ID value.

All str slice data resides in a global cache. There is no way to purge the cache once a str slice has been interned. This library is not intended for long running programs.

Dependencies

~115KB