macros: Implement Display for attributes.

This commit is contained in:
Emmanuel Gil Peyrot 2019-10-18 13:05:33 +02:00
parent 8c21efb2ac
commit 7b536e5bfc

View file

@ -85,6 +85,13 @@ macro_rules! generate_attribute {
})
}
}
impl std::fmt::Display for $elem {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
write!(fmt, "{}", match self {
$($elem::$a => $b),+
})
}
}
impl ::minidom::IntoAttributeValue for $elem {
fn into_attribute_value(self) -> Option<String> {
Some(String::from(match self {