From e7e4284a0dfa59ea649a4c4a6eb31d9070d13aba Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sun, 21 May 2017 21:02:06 +0100 Subject: [PATCH] jingle_ft: Obtain attributes using the get_attr! macro. --- src/jingle_ft.rs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/jingle_ft.rs b/src/jingle_ft.rs index 9dd69df..454ce8d 100644 --- a/src/jingle_ft.rs +++ b/src/jingle_ft.rs @@ -138,11 +138,8 @@ impl<'a> TryFrom<&'a Element> for Description { if range.is_some() { return Err(Error::ParseError("File must not have more than one range.")); } - let offset = file_payload.attr("offset").unwrap_or("0").parse()?; - let length = match file_payload.attr("length") { - Some(length) => Some(length.parse()?), - None => None, - }; + let offset = get_attr!(file_payload, "offset", default); + let length = get_attr!(file_payload, "length", optional); let mut range_hashes = vec!(); for hash_element in file_payload.children() { if !hash_element.is("hash", ns::HASHES) {