Use fixed seeds with ahash

This commit is contained in:
mo8it
2024-08-08 23:48:54 +02:00
parent 1b9faa4d61
commit e41c3a7c92
6 changed files with 18 additions and 19 deletions
+10
View File
@@ -0,0 +1,10 @@
use ahash::AHasher;
use std::hash::BuildHasherDefault;
/// DOS attacks aren't a concern for Rustlings. Therefore, we use `ahash` with fixed seeds.
pub type HashSet<T> = std::collections::HashSet<T, BuildHasherDefault<AHasher>>;
#[inline]
pub fn hash_set_with_capacity<T>(capacity: usize) -> HashSet<T> {
HashSet::with_capacity_and_hasher(capacity, BuildHasherDefault::<AHasher>::default())
}