Do some manual formatting in macros.

This commit is contained in:
Emmanuel Gil Peyrot 2018-12-29 18:29:11 +01:00
parent f6593aa74b
commit 96c8b05677
4 changed files with 47 additions and 44 deletions

View file

@ -29,7 +29,7 @@ macro_rules! get_attr {
"Required attribute '",
$attr,
"' missing."
)))
)));
}
}
};
@ -169,9 +169,12 @@ macro_rules! generate_element_enum {
}
impl From<$elem> for ::minidom::Element {
fn from(elem: $elem) -> ::minidom::Element {
::minidom::Element::builder(match elem {
::minidom::Element::builder(
match elem {
$($elem::$enum => $enum_name,)+
}).ns(crate::ns::$ns)
}
)
.ns(crate::ns::$ns)
.build()
}
}

View file

@ -102,7 +102,7 @@ impl TryFrom<Element> for Actor {
(Some(_), Some(_)) | (None, None) => {
return Err(Error::ParseError(
"Either 'jid' or 'nick' attribute is required.",
))
));
}
(Some(jid), _) => Ok(Actor::Jid(jid)),
(_, Some(nick)) => Ok(Actor::Nick(nick)),

View file

@ -136,7 +136,7 @@ impl FromStr for Type {
_ => {
return Err(Error::ParseError(
"Invalid 'type' attribute on presence element.",
))
));
}
})
}

View file

@ -138,7 +138,7 @@ fn parse_items(elem: Element, node: NodeName) -> Result<PubSubEvent, Error> {
Some(true) => {
return Err(Error::ParseError(
"Mix of item and retract in items element.",
))
));
}
}
items.push(Item::try_from(child.clone())?);
@ -149,7 +149,7 @@ fn parse_items(elem: Element, node: NodeName) -> Result<PubSubEvent, Error> {
Some(false) => {
return Err(Error::ParseError(
"Mix of item and retract in items element.",
))
));
}
}
check_no_children!(child, "retract");