diff options
| author | mo8it <mo8it@proton.me> | 2024-08-08 23:46:21 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-08-08 23:48:54 +0200 |
| commit | e41c3a7c925387ca2c2441b4f41c963b95bc828d (patch) | |
| tree | 02cf55dc72a489b6908141eabf57b48dfdc6cb45 /src/collections.rs | |
| parent | 1b9faa4d61665074fe450277644974dd0167e6e9 (diff) | |
Use fixed seeds with ahash
Diffstat (limited to 'src/collections.rs')
| -rw-r--r-- | src/collections.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/collections.rs b/src/collections.rs new file mode 100644 index 0000000..fa9e3fa --- /dev/null +++ b/src/collections.rs @@ -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()) +} |
