From e41c3a7c925387ca2c2441b4f41c963b95bc828d Mon Sep 17 00:00:00 2001 From: mo8it Date: Thu, 8 Aug 2024 23:46:21 +0200 Subject: Use fixed seeds with ahash --- src/collections.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 src/collections.rs (limited to 'src/collections.rs') 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 = std::collections::HashSet>; + +#[inline] +pub fn hash_set_with_capacity(capacity: usize) -> HashSet { + HashSet::with_capacity_and_hasher(capacity, BuildHasherDefault::::default()) +} -- cgit v1.2.3