use rustc_hash::FxHasher;
use std::any::{Any, TypeId};
use std::collections::HashMap;
use std::hash::BuildHasherDefault;
use std::sync::Arc;
#[derive(Clone, Debug, Default)]
pub struct Dimensions {
index: HashMap<TypeId, Arc<dyn Any + Send + Sync>, BuildHasherDefault<FxHasher>>,
}
impl Dimensions {
pub fn get_value<K: 'static, V: 'static>(&self) -> Option<&V> {
self.index.get(&TypeId::of::<K>()).and_then(|any| any.downcast_ref::<V>())
}
pub fn set_value<K: 'static, V: 'static + Sync + Send>(&mut self, value: V) {
self.index.insert(TypeId::of::<K>(), Arc::new(value));
}
}