Skip to content

Commit 51d94eb

Browse files
committed
Combine Map's Hash into one impl
1 parent 5e7bedc commit 51d94eb

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/map.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -370,20 +370,19 @@ impl PartialEq for Map<String, Value> {
370370

371371
impl Eq for Map<String, Value> {}
372372

373-
#[cfg(not(feature = "preserve_order"))]
374373
impl Hash for Map<String, Value> {
375-
#[inline]
376374
fn hash<H: Hasher>(&self, state: &mut H) {
377-
self.map.hash(state);
378-
}
379-
}
375+
#[cfg(not(feature = "preserve_order"))]
376+
{
377+
self.map.hash(state);
378+
}
380379

381-
#[cfg(feature = "preserve_order")]
382-
impl Hash for Map<String, Value> {
383-
fn hash<H: Hasher>(&self, state: &mut H) {
384-
let mut kv = Vec::from_iter(&self.map);
385-
kv.sort_unstable_by(|a, b| a.0.cmp(b.0));
386-
kv.hash(state);
380+
#[cfg(feature = "preserve_order")]
381+
{
382+
let mut kv = Vec::from_iter(&self.map);
383+
kv.sort_unstable_by(|a, b| a.0.cmp(b.0));
384+
kv.hash(state);
385+
}
387386
}
388387
}
389388

0 commit comments

Comments
 (0)