lxy 0.1.1

A convenient async http and RPC framework in Rust
Documentation
use std::{
  any::TypeId,
  collections::HashMap,
  hash::{BuildHasherDefault, Hasher},
};

#[derive(Default)]
pub struct TypeIdHasher(u64);

/// A simple hasher for TypeId that uses its internal u64 representation.
impl Hasher for TypeIdHasher {
  fn write(&mut self, _: &[u8]) {
    unreachable!("TypeId calls write_u64");
  }

  #[inline]
  fn write_u64(&mut self, id: u64) {
    self.0 = id;
  }

  #[inline]
  fn finish(&self) -> u64 {
    self.0
  }
}

pub type TypedMap<T> = HashMap<TypeId, T, BuildHasherDefault<TypeIdHasher>>;