diff --git a/src/features/impl_std.rs b/src/features/impl_std.rs index e0b7b4bc..96721053 100644 --- a/src/features/impl_std.rs +++ b/src/features/impl_std.rs @@ -444,16 +444,18 @@ where Ok(map) } } -impl<'de, K, V> BorrowDecode<'de> for HashMap +impl<'de, K, V, S> BorrowDecode<'de> for HashMap where K: BorrowDecode<'de> + Eq + std::hash::Hash, V: BorrowDecode<'de>, + S: std::hash::BuildHasher + Default, { fn borrow_decode>(decoder: &mut D) -> Result { let len = crate::de::decode_slice_len(decoder)?; decoder.claim_container_read::<(K, V)>(len)?; - let mut map = HashMap::with_capacity(len); + let hash_builder: S = Default::default(); + let mut map = HashMap::with_capacity_and_hasher(len, hash_builder); for _ in 0..len { // See the documentation on `unclaim_bytes_read` as to why we're doing this here decoder.unclaim_bytes_read(core::mem::size_of::<(K, V)>());