rustmotion_core/
macros.rs1#[macro_export]
15macro_rules! impl_traits {
16 ($type:ty { $($trait_name:ident => $field:ident),* $(,)? }) => {
17 $(
18 $crate::impl_traits!(@single $type, $trait_name, $field);
19 )*
20 };
21
22 (@single $type:ty, Animatable, $_field:ident) => {
23 impl $crate::traits::Animatable for $type {
24 fn animation_effects(&self) -> &[$crate::schema::AnimationEffect] {
25 &self.style.animation
26 }
27
28 fn timeline_steps(&self) -> &[$crate::schema::TimelineStep] {
29 &self.timeline
30 }
31 }
32 };
33
34 (@single $type:ty, Timed, $field:ident) => {
35 impl $crate::traits::Timed for $type {
36 fn timing(&self) -> (Option<f64>, Option<f64>) {
37 (self.$field.start_at, self.$field.end_at)
38 }
39 }
40 };
41
42 (@single $type:ty, Styled, $field:ident) => {
43 impl $crate::traits::Styled for $type {
44 fn style_config(&self) -> &$crate::css::CssStyle {
45 &self.$field
46 }
47 }
48
49 impl $crate::traits::StyledMut for $type {
50 fn style_config_mut(&mut self) -> &mut $crate::css::CssStyle {
51 &mut self.$field
52 }
53 }
54 };
55}