transform and components
This commit is contained in:
@@ -35,3 +35,53 @@ macro_rules! event {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! component {
|
||||
($name:ident) => {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct $name;
|
||||
|
||||
impl $crate::Component for $name {
|
||||
fn as_any(&self) -> &dyn std::any::Any {
|
||||
self
|
||||
}
|
||||
|
||||
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
|
||||
self
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
($name:ident {$($inner:tt)*}) => {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct $name {
|
||||
$($inner)*
|
||||
}
|
||||
|
||||
impl $crate::Component for $name {
|
||||
fn as_any(&self) -> &dyn std::any::Any {
|
||||
self
|
||||
}
|
||||
|
||||
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
|
||||
self
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
($name:ident ($($inner:tt)*)) => {
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct $name ($($inner)*);
|
||||
|
||||
impl $crate::Component for $name {
|
||||
fn as_any(&self) -> &dyn std::any::Any {
|
||||
self
|
||||
}
|
||||
|
||||
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
|
||||
self
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user