summaryrefslogtreecommitdiff
path: root/src/xmlelements.rs
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2019-06-26 06:01:12 -0500
committertom barrett <spalf0@gmail.com>2019-06-26 06:01:12 -0500
commitf7bbf5646c8220bca2fbd9451d5c234049cf9225 (patch)
tree735d0d448c060b6bdab0de395b0a0e620fb6a6f2 /src/xmlelements.rs
parent53b4ccdcc6cdac3b02480a97a2ec30439114ff6c (diff)
clippy and fmt
Diffstat (limited to 'src/xmlelements.rs')
-rw-r--r--src/xmlelements.rs27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/xmlelements.rs b/src/xmlelements.rs
index bf9a213..d05e9ff 100644
--- a/src/xmlelements.rs
+++ b/src/xmlelements.rs
@@ -14,11 +14,18 @@ pub struct Property {
impl Property {
pub fn new(property_elements: Vec<XmlEvent>) -> Property {
-
- let entity = XMLElements::get_attribute_value(&property_elements, "entity").unwrap().parse().unwrap();
- let keyframe =
- XMLElements::get_attribute_value(&property_elements, "keyframe").unwrap().parse().unwrap();
- let delay = XMLElements::get_attribute_value(&property_elements, "delay").unwrap().parse().unwrap();
+ let entity = XMLElements::get_attribute_value(&property_elements, "entity")
+ .unwrap()
+ .parse()
+ .unwrap();
+ let keyframe = XMLElements::get_attribute_value(&property_elements, "keyframe")
+ .unwrap()
+ .parse()
+ .unwrap();
+ let delay = XMLElements::get_attribute_value(&property_elements, "delay")
+ .unwrap()
+ .parse()
+ .unwrap();
Property {
entity,
@@ -126,18 +133,12 @@ impl XMLElements {
}
}
- pub fn get_attribute_value(
- elements: &Vec<XmlEvent>,
- attribute_name: &str,
- ) -> Result<String, ()> {
+ pub fn get_attribute_value(elements: &[XmlEvent], attribute_name: &str) -> Result<String, ()> {
let element = elements
.iter()
.find(|e| {
if let StartElement { attributes, .. } = e {
- attributes
- .iter()
- .find(|a| a.value == attribute_name)
- .is_some()
+ attributes.iter().any(|a| a.value == attribute_name)
} else {
false
}