11 releases (5 breaking)

Uses old Rust 2015

0.6.0 Apr 5, 2018
0.5.3 Mar 26, 2018
0.4.0 Mar 20, 2018
0.3.1 Mar 4, 2018
0.1.0 Feb 28, 2018

#823 in Rust patterns

Download history 62/week @ 2022-11-28 106/week @ 2022-12-05 118/week @ 2022-12-12 126/week @ 2022-12-19 56/week @ 2022-12-26 40/week @ 2023-01-02 59/week @ 2023-01-09 33/week @ 2023-01-16 87/week @ 2023-01-23 112/week @ 2023-01-30 104/week @ 2023-02-06 99/week @ 2023-02-13 117/week @ 2023-02-20 18/week @ 2023-02-27 99/week @ 2023-03-06 56/week @ 2023-03-13

312 downloads per month
Used in 7 crates (5 directly)


681 lines


Docs.rs Build Status codecov

Interned string and more for rust.

What is interning?

Interning is a method to store exactly one copy of immutable data.

Imagine your program holds lots of string values, mostly same value in it, and does not mutate them at all. If you use String to store them, lots of memories are wasted just for storing identical texts.

Interning efficiently eliminate this problem by managing global pool of cache, in the case above the type of the pool can be HashSet<Rc<str>>. When you need a new owned string, first you should lookup global pool for it. If desired string is found then use it. If not, just create a new one and put them also to the pool.

Or, you can just use internship and ignore all the hassle. Why not?

What does this library provide?

This crate exposes a set of interned types which correspond to Rc but guaranteed to be unique over its value within thread. Instances of them are per-thread cached to archive this goal.

Additionally, these types does not heap-allocate small data that can be fit on stack. Size limit of inline-able data is 15 bytes on 64-byte machines.

IStr, IBytes, and ICStr correspond to str, [u8], and CStr respectively.


This repository is dual-licensed under the MIT license and Apache license 2.0 at your option. By contributing to Internship you agree that your contributions will be licensed under these two licenses.