Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,31 @@
//! Some operations are even slightly more efficient and it consumes less memory.
//! However, all this is at the costs of a less efficient resolution of symbols.
//! Note that the symbols generated by the `BufferBackend` are not contiguous.
//!
//! ## Customizing String Hashing
//!
//! To ensure only one copy of each string is interned, [`StringInterner`] relies on [hashbrown]'s
//! [hashmap](hashbrown::HashMap), which necessitates choosing a hashing function for hashing the
//! strings.
//!
//! By default, [`StringInterner`] will use hashbrown's [`DefaultHashBuilder`], which should be
//! appropriate for most users. However, you may customize the hash function via
//! [`StringInterner`]'s second type parameter:
//!
//! ```
//! use std::hash::RandomState;
//! use string_interner::{StringInterner, DefaultBackend};
//!
//! // create a StringInterner with the default backend but using std's RandomState hasher
//! let interned_strs: StringInterner<DefaultBackend, RandomState> = StringInterner::new();
//! ```
//!
//! NB: as of hashbrown v0.15.2, the [`DefaultHashBuilder`] is [foldhash's
//! RandomState](https://docs.rs/foldhash/latest/foldhash/fast/struct.RandomState.html), which
//! relies on a one-time random initialization of shared global state; if you need stable hashes
//! then you may wish to use [foldhash's
//! FixedState](https://docs.rs/foldhash/latest/foldhash/fast/struct.FixedState.html) (or similar)
//! instead.

extern crate alloc;
#[cfg(feature = "std")]
Expand Down
Loading