Skip to content

Commit a1a76e1

Browse files
committed
Add note about const-ness of with_hasher
1 parent 68da212 commit a1a76e1

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/map.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,12 @@ impl<K, V, S> IndexMap<K, V, S> {
175175
}
176176
}
177177

178-
/// Create a new map with `hash_builder`
178+
/// Create a new map with `hash_builder`.
179+
///
180+
/// This function is `const`, so it
181+
/// can be called in `static` contexts.
182+
/// If you need `hash_builder` that can be made in the static context,
183+
/// consider [`ahash`](https://docs.rs/ahash/0.7.4/ahash/struct.RandomState.html#method.with_seeds).
179184
pub const fn with_hasher(hash_builder: S) -> Self {
180185
IndexMap {
181186
core: IndexMapCore::new(),

src/set.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,12 @@ impl<T, S> IndexSet<T, S> {
155155
}
156156
}
157157

158-
/// Create a new set with `hash_builder`
158+
/// Create a new set with `hash_builder`.
159+
///
160+
/// This function is `const`, so it
161+
/// can be called in `static` contexts.
162+
/// If you need `hash_builder` that can be made in the static context,
163+
/// consider [`ahash`](https://docs.rs/ahash/0.7.4/ahash/struct.RandomState.html#method.with_seeds).
159164
pub const fn with_hasher(hash_builder: S) -> Self {
160165
IndexSet {
161166
map: IndexMap::with_hasher(hash_builder),

0 commit comments

Comments
 (0)