fluent_ansi/
styling_attribute.rs1pub trait StylingAttribute<S> {
3 type Value: Default;
5
6 #[must_use]
8 fn set_in(self, composed_styling: S, value: Self::Value) -> S;
9
10 #[must_use]
12 fn get_from(self, composed_styling: &S) -> Self::Value;
13}
14
15macro_rules! impl_styling_atribute_for {
16 {$type:ty {
17 type Value = $value_type:ty;
18 args: [$self:ident, $composed_styling:ident, $value:ident];
19 set_in: $set_in:block
20 get_from: $get_from:block
21 }} => {
22 impl $crate::StylingAttribute<$crate::Style> for $type {
23 type Value = $value_type;
24
25 fn set_in($self, $composed_styling: $crate::Style, $value: Self::Value) -> $crate::Style {
26 $set_in
27 }
28
29 fn get_from($self, $composed_styling: &$crate::Style) -> Self::Value {
30 $get_from
31 }
32 }
33
34 impl<C: Display> $crate::StylingAttribute<$crate::Styled<C>> for $type {
35 type Value = $value_type;
36
37 fn set_in($self, $composed_styling: $crate::Styled<C>, $value: Self::Value) -> $crate::Styled<C> {
38 $set_in
39 }
40
41 fn get_from($self, $composed_styling: &$crate::Styled<C>) -> Self::Value {
42 $get_from
43 }
44 }
45 };
46}
47pub(crate) use impl_styling_atribute_for;