use std::hash::{Hash, Hasher};
use AsBytes;
#[derive(PartialEq, RustcEncodable, RustcDecodable, 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())
}
}