veloren_common/util/
grid_hasher.rs1use std::hash::{BuildHasher, Hasher};
2
3#[derive(Copy, Clone, Default)]
4pub struct GridHasher(u64);
5
6impl Hasher for GridHasher {
12 fn finish(&self) -> u64 { self.0 }
13
14 fn write(&mut self, _: &[u8]) {
15 panic!("Hashing arbitrary bytes is unimplemented");
16 }
17
18 fn write_i32(&mut self, x: i32) { self.0 = self.0.wrapping_mul(113989) ^ self.0 ^ x as u64; }
19}
20
21impl BuildHasher for GridHasher {
22 type Hasher = Self;
23
24 fn build_hasher(&self) -> Self::Hasher { *self }
25}