From 5e7bedc0a0e19ecda1c15a412ab7c69569f4aa84 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 24 Jun 2024 21:33:38 -0700 Subject: [PATCH] Touch up PR 1127 --- src/map.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/map.rs b/src/map.rs index 5360a69e0..c0ad32747 100644 --- a/src/map.rs +++ b/src/map.rs @@ -12,7 +12,7 @@ use alloc::string::String; use alloc::vec::Vec; use core::borrow::Borrow; use core::fmt::{self, Debug}; -use core::hash::Hash; +use core::hash::{Hash, Hasher}; use core::iter::FusedIterator; #[cfg(feature = "preserve_order")] use core::mem; @@ -373,15 +373,15 @@ impl Eq for Map {} #[cfg(not(feature = "preserve_order"))] impl Hash for Map { #[inline] - fn hash(&self, state: &mut H) { + fn hash(&self, state: &mut H) { self.map.hash(state); } } + #[cfg(feature = "preserve_order")] impl Hash for Map { - #[inline] - fn hash(&self, state: &mut H) { - let mut kv = self.map.iter().collect::>(); + fn hash(&self, state: &mut H) { + let mut kv = Vec::from_iter(&self.map); kv.sort_unstable_by(|a, b| a.0.cmp(b.0)); kv.hash(state); }