use std::any::{Any, TypeId}; use crate::util::{HashMap, Id}; #[derive(Default)] pub struct UiData { map: HashMap>, } impl UiData { pub fn get(&self) -> Option<&T> { self.map .get(&TypeId::of::()) .map(|d| d.downcast_ref().unwrap()) } pub fn get_mut(&mut self) -> Option<&mut T> { self.map .get_mut(&TypeId::of::()) .map(|d| d.downcast_mut().unwrap()) } pub fn emit_remove(&mut self, id: &Id) { for (tid, f) in &mut self.on_remove { let data = self.map.get_mut(tid).unwrap().downcast_ref().unwrap(); } } }