We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
core::hash
1 parent a171994 commit 79643adCopy full SHA for 79643ad
library/coretests/tests/hash/mod.rs
@@ -53,12 +53,14 @@ fn test_writer_hasher() {
53
assert_eq!(hash(&5_u16), 5);
54
assert_eq!(hash(&5_u32), 5);
55
assert_eq!(hash(&5_u64), 5);
56
+ assert_eq!(hash(&5_u128), 5);
57
assert_eq!(hash(&5_usize), 5);
58
59
assert_eq!(hash(&5_i8), 5);
60
assert_eq!(hash(&5_i16), 5);
61
assert_eq!(hash(&5_i32), 5);
62
assert_eq!(hash(&5_i64), 5);
63
+ assert_eq!(hash(&5_i128), 5);
64
assert_eq!(hash(&5_isize), 5);
65
66
assert_eq!(hash(&false), 0);
@@ -85,6 +87,17 @@ fn test_writer_hasher() {
85
87
let ptr = ptr::without_provenance_mut::<i32>(5_usize);
86
88
assert_eq!(hash(&ptr), 5);
89
90
+ // Use a newtype to test the `Hash::hash_slice` default implementation.
91
+ struct Byte(u8);
92
+
93
+ impl Hash for Byte {
94
+ fn hash<H: Hasher>(&self, state: &mut H) {
95
+ state.write_u8(self.0)
96
+ }
97
98
99
+ assert_eq!(hash(&[Byte(b'a')]), 97 + 1);
100
101
if cfg!(miri) {
102
// Miri cannot hash pointers
103
return;
0 commit comments