From 74f43e9ffe76d81b3ecea7381feadbc3942d238d Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Thu, 4 Jan 2024 20:43:46 -0500 Subject: [PATCH] reflect: implement TypeData for T --- lyra-reflect/src/registry.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lyra-reflect/src/registry.rs b/lyra-reflect/src/registry.rs index 5b264c8..0311f10 100644 --- a/lyra-reflect/src/registry.rs +++ b/lyra-reflect/src/registry.rs @@ -45,6 +45,20 @@ pub trait TypeData: std::any::Any { fn boxed_clone(&self) -> Box; } +impl TypeData for T { + fn as_any(&self) -> &dyn std::any::Any { + self + } + + fn as_any_mut(&mut self) -> &mut dyn std::any::Any { + self + } + + fn boxed_clone(&self) -> Box { + Box::new(self.clone()) + } +} + #[derive(Default)] pub struct RegisteredType { data: HashMap>,