use multi_trait_object::MultitraitObject; use std::any::TypeId; use std::collections::HashMap; #[derive(Debug, Default)] pub(crate) struct TypeMapBase(pub(crate) HashMap); impl TypeMapBase { #[inline] pub fn new() -> Self { Self::default() } #[inline] pub fn insert(&mut self, value: MultitraitObject) { self.0.insert(TypeId::of::(), value); } #[inline] pub fn get(&self) -> Option<&MultitraitObject> { self.0.get(&TypeId::of::()) } #[inline] pub fn get_mut(&mut self) -> Option<&mut MultitraitObject> { self.0.get_mut(&TypeId::of::()) } #[inline] pub fn remove(&mut self) -> Option { self.0.remove(&TypeId::of::()) } #[inline] pub fn contains_key(&self) -> bool { self.0.contains_key(&TypeId::of::()) } }