ncollide3d/utils/
hashable_partial_eq.rsuse 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())
}
}