Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ doc = true
[features]
default = ["std", "runtime-rng"]

mem_dbg = ["dep:mem_dbg", "std"]

# Enabling this will enable `AHashMap` and `AHashSet`.
std = []

Expand Down Expand Up @@ -85,6 +87,7 @@ cfg-if = "1.0"
portable-atomic = { version = "1.0.0", optional = true }
getrandom = { version = "0.2.7", optional = true }
zerocopy = { version = "0.7.31", default-features = false, features = ["simd"] }
mem_dbg = {version="0.2.4", optional = true}

[target.'cfg(not(all(target_arch = "arm", target_os = "none")))'.dependencies]
once_cell = { version = "1.18.0", default-features = false, features = ["alloc"] }
Expand Down
2 changes: 2 additions & 0 deletions benchmark_tools/src/persisting_hasher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use std::process::id;
static GLOBAL_COUNT: AtomicU64 = AtomicU64::new(0);
static GLOBAL_OUT: OnceCell<Arc<Mutex<BufWriter<File>>>> = OnceCell::new();

#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
pub struct PersistingHasherBuilder {
id: u64,
out: Arc<Mutex<BufWriter<File>>>,
Expand Down Expand Up @@ -44,6 +45,7 @@ impl BuildHasher for PersistingHasherBuilder {
}
}

#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
pub struct PersistingHasher {
/// Used to compute a hash
hash: u64,
Expand Down
4 changes: 4 additions & 0 deletions src/aes_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use core::hash::Hasher;
/// start with the same data.
///
#[derive(Debug, Clone)]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
pub struct AHasher {
enc: u128,
sum: u128,
Expand Down Expand Up @@ -215,6 +216,7 @@ impl Hasher for AHasher {
}

#[cfg(feature = "specialize")]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
pub(crate) struct AHasherU64 {
pub(crate) buffer: u64,
pub(crate) pad: u64,
Expand Down Expand Up @@ -265,6 +267,7 @@ impl Hasher for AHasherU64 {
}

#[cfg(feature = "specialize")]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
pub(crate) struct AHasherFixed(pub AHasher);

/// A specialized hasher for fixed size primitives larger than 64 bits.
Expand Down Expand Up @@ -312,6 +315,7 @@ impl Hasher for AHasherFixed {
}

#[cfg(feature = "specialize")]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
pub(crate) struct AHasherStr(pub AHasher);

/// A specialized hasher for strings
Expand Down
4 changes: 4 additions & 0 deletions src/fallback_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const ROT: u32 = 23; //17
/// start with the same data.
///
#[derive(Debug, Clone)]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
pub struct AHasher {
buffer: u64,
pad: u64,
Expand Down Expand Up @@ -200,6 +201,7 @@ impl Hasher for AHasher {
}

#[cfg(feature = "specialize")]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
pub(crate) struct AHasherU64 {
pub(crate) buffer: u64,
pub(crate) pad: u64,
Expand Down Expand Up @@ -251,6 +253,7 @@ impl Hasher for AHasherU64 {
}

#[cfg(feature = "specialize")]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
pub(crate) struct AHasherFixed(pub AHasher);

/// A specialized hasher for fixed size primitives larger than 64 bits.
Expand Down Expand Up @@ -298,6 +301,7 @@ impl Hasher for AHasherFixed {
}

#[cfg(feature = "specialize")]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
pub(crate) struct AHasherStr(pub AHasher);

/// A specialized hasher for a single string
Expand Down
1 change: 1 addition & 0 deletions src/hash_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::RandomState;
/// A [`HashMap`](std::collections::HashMap) using [`RandomState`](crate::RandomState) to hash the items.
/// (Requires the `std` feature to be enabled.)
#[derive(Clone)]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
pub struct AHashMap<K, V, S = crate::RandomState>(HashMap<K, V, S>);

impl<K, V> From<HashMap<K, V, crate::RandomState>> for AHashMap<K, V> {
Expand Down
1 change: 1 addition & 0 deletions src/hash_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use serde::{
/// A [`HashSet`](std::collections::HashSet) using [`RandomState`](crate::RandomState) to hash the items.
/// (Requires the `std` feature to be enabled.)
#[derive(Clone)]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
pub struct AHashSet<T, S = RandomState>(HashSet<T, S>);

impl<T> From<HashSet<T, RandomState>> for AHashSet<T> {
Expand Down
1 change: 1 addition & 0 deletions src/random_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ cfg_if::cfg_if! {
/// |`with_seeds` | Fixed |`u64` x 4|
///
#[derive(Clone)]
#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
pub struct RandomState {
pub(crate) k0: u64,
pub(crate) k1: u64,
Expand Down
1 change: 1 addition & 0 deletions tests/nopanic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fn hash_test_final_wrapper(num: i32, string: &str) {
hash_test_final(num, string);
}

#[cfg_attr(feature = "mem_dbg", derive(mem_dbg::MemSize, mem_dbg::MemDbg))]
struct SimpleBuildHasher {
hasher: AHasher,
}
Expand Down