#[macro_export]
macro_rules! impl_default_coercion_rule {
($Type:ty, $Variant:path) => {
impl CoercionRules for $Type {
fn try_coerce(pax_value: PaxValue) -> Result<Self, String> {
if let $Variant(val) = pax_value {
Ok(val.into())
} else {
Err(format!(
"couldn't coerce {:?} into {}",
pax_value,
std::any::type_name::<$Type>()
))
}
}
}
};
}
#[macro_export]
macro_rules! impl_to_from_pax_value {
($Type:ty, $Variant:path) => {
impl ToPaxValue for $Type {
fn to_pax_value(self) -> PaxValue {
$Variant(self)
}
}
};
($Type:ty, $OuterVariant:path, $InnerVariant:path) => {
impl ToPaxValue for $Type {
fn to_pax_value(self) -> PaxValue {
$OuterVariant($InnerVariant(self))
}
}
};
}