any_map/
hasher.rs

1#[cfg(feature = "fnv")]
2pub(crate) use fnv::FnvHasher as Hasher;
3
4#[cfg(not(feature = "fnv"))]
5pub(crate) use self::id_hasher::IdHasher as Hasher;
6
7#[cfg(not(feature = "fnv"))]
8pub mod id_hasher {
9    // Copy from https://github.com/hyperium/http/blob/v0.2.6/src/extensions.rs#L8-L28
10    #[derive(Default)]
11    pub struct IdHasher(u64);
12
13    impl core::hash::Hasher for IdHasher {
14        fn write(&mut self, _: &[u8]) {
15            unreachable!("TypeId calls write_u64");
16        }
17
18        #[inline]
19        fn write_u64(&mut self, id: u64) {
20            self.0 = id;
21        }
22
23        #[inline]
24        fn finish(&self) -> u64 {
25            self.0
26        }
27    }
28}