rsm, ibb: Write and use a macro to parse attributes.

This commit is contained in:
Emmanuel Gil Peyrot 2017-05-21 16:03:17 +01:00
commit 3c083709cb
3 changed files with 34 additions and 25 deletions

View file

@ -61,10 +61,7 @@ impl<'a> TryFrom<&'a Element> for Set {
if set.first.is_some() {
return Err(Error::ParseError("Set cant have more than one first."));
}
set.first_index = match child.attr("index") {
Some(index) => Some(index.parse()?),
None => None,
};
set.first_index = get_attr!(child, "index", optional, index, index.parse()?);
set.first = Some(child.text());
} else if child.is("index", ns::RSM) {
if set.index.is_some() {