reflect: implement TypeData for T
This commit is contained in:
parent
67c5876443
commit
74f43e9ffe
|
@ -45,6 +45,20 @@ pub trait TypeData: std::any::Any {
|
||||||
fn boxed_clone(&self) -> Box<dyn TypeData>;
|
fn boxed_clone(&self) -> Box<dyn TypeData>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: Clone + 'static> 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<dyn TypeData> {
|
||||||
|
Box::new(self.clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct RegisteredType {
|
pub struct RegisteredType {
|
||||||
data: HashMap<TypeId, Box<dyn TypeData>>,
|
data: HashMap<TypeId, Box<dyn TypeData>>,
|
||||||
|
|
Loading…
Reference in New Issue