macro_rules! impl_predicate_debug_display {
($struct_name:ident < $t:ident >) => {
impl<$t> std::fmt::Debug for $struct_name<$t> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct(stringify!($struct_name))
.field("name", &self.metadata.name())
.field("function", &"<function>")
.finish()
}
}
impl<$t> std::fmt::Display for $struct_name<$t> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.metadata.name() {
Some(name) => {
write!(f, "{}({})", stringify!($struct_name), name)
}
None => {
write!(f, "{}({})", stringify!($struct_name), "unnamed")
}
}
}
}
};
($struct_name:ident < $t:ident, $u:ident >) => {
impl<$t, $u> std::fmt::Debug for $struct_name<$t, $u> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.debug_struct(stringify!($struct_name))
.field("name", &self.metadata.name())
.field("function", &"<function>")
.finish()
}
}
impl<$t, $u> std::fmt::Display for $struct_name<$t, $u> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.metadata.name() {
Some(name) => {
write!(f, "{}({})", stringify!($struct_name), name)
}
None => {
write!(f, "{}({})", stringify!($struct_name), "unnamed")
}
}
}
}
};
}
pub(crate) use impl_predicate_debug_display;