From dfb736a9731973626ec7c4c73dd991eb4e72f9e4 Mon Sep 17 00:00:00 2001 From: Emmanuel Gil Peyrot Date: Sat, 29 Jul 2017 03:03:45 +0100 Subject: [PATCH] rsm: Change if .is_some() { .unwrap() } into if let Some(). --- src/rsm.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rsm.rs b/src/rsm.rs index 008757dd..fa6f6c81 100644 --- a/src/rsm.rs +++ b/src/rsm.rs @@ -97,8 +97,8 @@ impl From for Element { if set.before.is_some() { elem.append_child(Element::builder("before").ns(ns::RSM).append(set.before).build()); } - if set.count.is_some() { - elem.append_child(Element::builder("count").ns(ns::RSM).append(format!("{}", set.count.unwrap())).build()); + if let Some(count) = set.count { + elem.append_child(Element::builder("count").ns(ns::RSM).append(format!("{}", count)).build()); } if set.first.is_some() { elem.append_child(Element::builder("first") @@ -106,14 +106,14 @@ impl From for Element { .attr("index", set.first_index) .append(set.first).build()); } - if set.index.is_some() { - elem.append_child(Element::builder("index").ns(ns::RSM).append(format!("{}", set.index.unwrap())).build()); + if let Some(index) = set.index { + elem.append_child(Element::builder("index").ns(ns::RSM).append(format!("{}", index)).build()); } if set.last.is_some() { elem.append_child(Element::builder("last").ns(ns::RSM).append(set.last).build()); } - if set.max.is_some() { - elem.append_child(Element::builder("max").ns(ns::RSM).append(format!("{}", set.max.unwrap())).build()); + if let Some(max) = set.max { + elem.append_child(Element::builder("max").ns(ns::RSM).append(format!("{}", max)).build()); } elem }