runtime_context/
hasher.rs1use std::{
2 any::TypeId,
3 collections::HashMap,
4 hash::{BuildHasherDefault, Hasher},
5};
6
7#[derive(Debug, Default)]
9pub struct TypeIdHasher(u64);
10
11pub type TypeMap<V> = HashMap<TypeId, V, BuildHasherDefault<TypeIdHasher>>;
13
14impl Hasher for TypeIdHasher {
15 fn write(&mut self, _: &[u8]) {
16 unimplemented!("This TypeIdHasher can only handle u64s")
17 }
18
19 fn write_u64(&mut self, i: u64) {
20 self.0 = i;
21 }
22
23 fn finish(&self) -> u64 {
24 self.0
25 }
26}