Skip to content

Commit d0f49bc

Browse files
author
Lexo
authored
Fix test test_hash (#351)
1 parent b079a9b commit d0f49bc

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/tests.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::{smallvec, SmallVec};
22

3+
use core::hash::Hasher;
34
use core::iter::FromIterator;
45

56
use alloc::borrow::ToOwned;
@@ -600,19 +601,24 @@ fn test_hash() {
600601
use std::collections::hash_map::DefaultHasher;
601602
use std::hash::Hash;
602603

604+
fn hash(value: impl Hash) -> u64 {
605+
let mut hasher = DefaultHasher::new();
606+
value.hash(&mut hasher);
607+
hasher.finish()
608+
}
609+
603610
{
604611
let mut a: SmallVec<u32, 2> = SmallVec::new();
605612
let b = [1, 2];
606613
a.extend(b.iter().cloned());
607-
let mut hasher = DefaultHasher::new();
608-
assert_eq!(a.hash(&mut hasher), b.hash(&mut hasher));
614+
assert_eq!(hash(a), hash(b));
609615
}
616+
610617
{
611618
let mut a: SmallVec<u32, 2> = SmallVec::new();
612619
let b = [1, 2, 11, 12];
613620
a.extend(b.iter().cloned());
614-
let mut hasher = DefaultHasher::new();
615-
assert_eq!(a.hash(&mut hasher), b.hash(&mut hasher));
621+
assert_eq!(hash(a), hash(b));
616622
}
617623
}
618624

0 commit comments

Comments
 (0)