internship/
lib.rs

1//! Interned string and more for rust.
2//!
3//! # What is interning?
4//!
5//! Interning is a method to store exactly one copy of immutable data.
6//!
7//! Imagine your program holds lots of string values, mostly same value in it,
8//! and does not mutate them at all. If you use `String` to store them,
9//! lots of memories are wasted just for storing identical texts.
10//!
11//! Interning efficiently eliminate this problem by managing global pool of cache,
12//! in the case above the type of the pool can be `HashSet<Rc<str>>`.
13//! When you need a new owned string, first you should lookup global pool for it.
14//! If desired string is found then use it.
15//! If not, just create a new one and put them also to the pool.
16//!
17//! Or, you can just use `internship` and ignore all the hassle. Why not?
18//!
19//! # What does this library provide?
20//!
21//! This crate exposes a set of interned types which correspond to `Rc`
22//! but guaranteed to be unique over its value within thread.
23//! Instances of them are per-thread cached to archive this goal.
24//!
25//! Additionally, these types does not heap-allocate small data that can be fit on stack.
26//! Size limit of inline-able data is 15 bytes on 64-byte machines.
27//!
28//! `IStr`, `IBytes`, and `ICStr` correspond to `str`, `[u8]`, and `CStr` respectively.
29
30#[cfg(feature = "serde-compat")]
31extern crate serde;
32
33mod handle;
34mod istr;
35mod ibytes;
36mod icstr;
37
38pub use istr::IStr;
39pub use ibytes::IBytes;
40pub use icstr::ICStr;