1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
use crate::utils::AsBytes;
use std::hash::{Hash, Hasher};
#[derive(PartialEq, Clone, Debug)]
pub struct HashablePartialEq<T> {
value: T,
}
impl<T> HashablePartialEq<T> {
pub unsafe fn new(value: T) -> HashablePartialEq<T> {
HashablePartialEq { value: value }
}
pub fn unwrap(self) -> T {
self.value
}
}
impl<T: PartialEq> Eq for HashablePartialEq<T> {}
impl<T: AsBytes> Hash for HashablePartialEq<T> {
#[inline]
fn hash<H: Hasher>(&self, state: &mut H) {
state.write(self.value.as_bytes())
}
}