File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 123123//! Some operations are even slightly more efficient and it consumes less memory.
124124//! However, all this is at the costs of a less efficient resolution of symbols.
125125//! Note that the symbols generated by the `BufferBackend` are not contiguous.
126+ //!
127+ //! ## Customizing String Hashing
128+ //!
129+ //! To ensure only one copy of each string is interned, [`StringInterner`] relies on [hashbrown]'s
130+ //! [hashmap](hashbrown::HashMap), which necessitates choosing a hashing function for hashing the
131+ //! strings.
132+ //!
133+ //! By default, [`StringInterner`] will use hashbrown's [`DefaultHashBuilder`], which should be
134+ //! appropriate for most users. However, you may customize the hash function via
135+ //! [`StringInterner`]'s second type parameter:
136+ //!
137+ //! ```
138+ //! use std::hash::RandomState;
139+ //! use string_interner::{StringInterner, DefaultBackend};
140+ //!
141+ //! // create a StringInterner with the default backend but using std's RandomState hasher
142+ //! let interned_strs: StringInterner<DefaultBackend, RandomState> = StringInterner::new();
143+ //! ```
144+ //!
145+ //! NB: as of hashbrown v0.15.2, the [`DefaultHashBuilder`] is [foldhash's
146+ //! RandomState](https://docs.rs/foldhash/latest/foldhash/fast/struct.RandomState.html), which
147+ //! relies on a one-time random initialization of shared global state; if you need stable hashes
148+ //! then you may wish to use [foldhash's
149+ //! FixedState](https://docs.rs/foldhash/latest/foldhash/fast/struct.FixedState.html) (or similar)
150+ //! instead.
126151
127152extern crate alloc;
128153#[ cfg( feature = "std" ) ]
You can’t perform that action at this time.
0 commit comments