From 3811448313b0a991ed843dc85e713fe313c0a01f Mon Sep 17 00:00:00 2001 From: Thierry Berger Date: Tue, 23 Jul 2024 16:11:33 +0200 Subject: [PATCH] fix cargo +nightly build --- src/utils/hashmap.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/utils/hashmap.rs b/src/utils/hashmap.rs index 364ae380..a5d02a3d 100644 --- a/src/utils/hashmap.rs +++ b/src/utils/hashmap.rs @@ -6,6 +6,8 @@ use indexmap::IndexMap as StdHashMap; #[cfg(all(not(feature = "enhanced-determinism"), feature = "serde-serialize"))] use std::collections::HashMap as StdHashMap; +use std::mem::size_of; + /// Serializes only the capacity of a hash-map instead of its actual content. #[cfg(feature = "serde-serialize")] pub fn serialize_hashmap_capacity( @@ -84,20 +86,20 @@ impl std::hash::Hasher for FxHasher32 { fn write(&mut self, mut bytes: &[u8]) { let read_u32 = |bytes: &[u8]| u32::from_ne_bytes(bytes[..4].try_into().unwrap()); let mut hash = FxHasher32 { hash: self.hash }; - assert!(std::mem::size_of::() <= 8); - while bytes.len() >= std::mem::size_of::() { + assert!(size_of::() <= 8); + while bytes.len() >= size_of::() { hash.add_to_hash(read_u32(bytes)); - bytes = &bytes[std::mem::size_of::()..]; + bytes = &bytes[size_of::()..]; } - if (std::mem::size_of::() > 4) && (bytes.len() >= 4) { + if (size_of::() > 4) && (bytes.len() >= 4) { hash.add_to_hash(u32::from_ne_bytes(bytes[..4].try_into().unwrap())); bytes = &bytes[4..]; } - if (std::mem::size_of::() > 2) && bytes.len() >= 2 { + if (size_of::() > 2) && bytes.len() >= 2 { hash.add_to_hash(u16::from_ne_bytes(bytes[..2].try_into().unwrap()) as u32); bytes = &bytes[2..]; } - if (std::mem::size_of::() > 1) && !bytes.is_empty() { + if (size_of::() > 1) && !bytes.is_empty() { hash.add_to_hash(bytes[0] as u32); } self.hash = hash.hash;