pub trait StylingAttribute<S> {
type Value: Default;
#[must_use]
fn set_in(self, composed_styling: S, value: Self::Value) -> S;
#[must_use]
fn get_from(self, composed_styling: &S) -> Self::Value;
}
macro_rules! impl_styling_atribute_for {
{$type:ty {
type Value = $value_type:ty;
args: [$self:ident, $composed_styling:ident, $value:ident];
set_in: $set_in:block
get_from: $get_from:block
}} => {
impl $crate::StylingAttribute<$crate::Style> for $type {
type Value = $value_type;
fn set_in($self, $composed_styling: $crate::Style, $value: Self::Value) -> $crate::Style {
$set_in
}
fn get_from($self, $composed_styling: &$crate::Style) -> Self::Value {
$get_from
}
}
impl<C: Display> $crate::StylingAttribute<$crate::Styled<C>> for $type {
type Value = $value_type;
fn set_in($self, $composed_styling: $crate::Styled<C>, $value: Self::Value) -> $crate::Styled<C> {
$set_in
}
fn get_from($self, $composed_styling: &$crate::Styled<C>) -> Self::Value {
$get_from
}
}
};
}
pub(crate) use impl_styling_atribute_for;