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
32
33
34
35
use std::mem;
use std::hash;
#[derive(Debug, Clone, Copy)]
pub struct BrokenF32(pub f32);
impl BrokenF32 {
fn key(&self) -> u32 {
unsafe { mem::transmute(self.0) }
}
}
impl hash::Hash for BrokenF32 {
fn hash<H>(&self, state: &mut H)
where
H: hash::Hasher,
{
self.key().hash(state)
}
}
impl PartialEq for BrokenF32 {
fn eq(&self, other: &Self) -> bool {
self.key() == other.key()
}
}
impl Eq for BrokenF32 {}