From a7d3637f6711cc96a5f6dc86772dba14fef1a013 Mon Sep 17 00:00:00 2001 From: aochagavia Date: Fri, 14 Mar 2014 17:29:47 +0100 Subject: [PATCH] Refactored iter and mut_iter Replaced match by self.as_ref() and self.as_mut() --- src/libstd/option.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/libstd/option.rs b/src/libstd/option.rs index d315e8e3219..49d40605c26 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -211,19 +211,13 @@ impl Option { /// Return an iterator over the possibly contained value #[inline] pub fn iter<'r>(&'r self) -> Item<&'r T> { - match *self { - Some(ref x) => Item{opt: Some(x)}, - None => Item{opt: None} - } + Item{opt: self.as_ref()} } /// Return a mutable iterator over the possibly contained value #[inline] pub fn mut_iter<'r>(&'r mut self) -> Item<&'r mut T> { - match *self { - Some(ref mut x) => Item{opt: Some(x)}, - None => Item{opt: None} - } + Item{opt: self.as_mut()} } /// Return a consuming iterator over the possibly contained value