|
24 | 24 | //! - The [`MutableKeys`][map::MutableKeys] trait, which gives opt-in mutable
|
25 | 25 | //! access to hash map keys.
|
26 | 26 | //!
|
| 27 | +//! ### Alternate Hashers |
| 28 | +//! |
| 29 | +//! [`IndexMap`] and [`IndexSet`] have a default hasher type `S = RandomState`, |
| 30 | +//! just like the standard `HashMap` and `HashSet`, which is resistant to |
| 31 | +//! HashDoS attacks but not the most performant. Type aliases can make it easier |
| 32 | +//! to use alternate hashers: |
| 33 | +//! |
| 34 | +//! ``` |
| 35 | +//! # extern crate fnv; |
| 36 | +//! # extern crate fxhash; |
| 37 | +//! use fnv::FnvBuildHasher; |
| 38 | +//! use fxhash::FxBuildHasher; |
| 39 | +//! use indexmap::{IndexMap, IndexSet}; |
| 40 | +//! |
| 41 | +//! type FnvIndexMap<K, V> = IndexMap<K, V, FnvBuildHasher>; |
| 42 | +//! type FnvIndexSet<T> = IndexSet<T, FnvBuildHasher>; |
| 43 | +//! |
| 44 | +//! type FxIndexMap<K, V> = IndexMap<K, V, FxBuildHasher>; |
| 45 | +//! type FxIndexSet<T> = IndexSet<T, FxBuildHasher>; |
| 46 | +//! |
| 47 | +//! let std: IndexSet<i32> = (0..100).collect(); |
| 48 | +//! let fnv: FnvIndexSet<i32> = (0..100).collect(); |
| 49 | +//! let fx: FxIndexSet<i32> = (0..100).collect(); |
| 50 | +//! assert_eq!(std, fnv); |
| 51 | +//! assert_eq!(std, fx); |
| 52 | +//! ``` |
| 53 | +//! |
27 | 54 | //! ### Rust Version
|
28 | 55 | //!
|
29 | 56 | //! This version of indexmap requires Rust 1.18 or later, or 1.32+ for
|
|
0 commit comments