about summary refs log tree commit diff
diff options
context:
space:
mode:
authoraochagavia <aochagavia92@gmail.com>2014-03-14 17:29:47 +0100
committeraochagavia <aochagavia92@gmail.com>2014-03-14 17:29:47 +0100
commita7d3637f6711cc96a5f6dc86772dba14fef1a013 (patch)
tree52ae8b4a3b3473e295a1f92ee6cb585937773d99
parentdcf320a6394c712aaeca1cd39f054b11c129af97 (diff)
downloadrust-a7d3637f6711cc96a5f6dc86772dba14fef1a013.tar.gz
rust-a7d3637f6711cc96a5f6dc86772dba14fef1a013.zip
Refactored iter and mut_iter
Replaced match by self.as_ref() and self.as_mut()
-rw-r--r--src/libstd/option.rs10
1 files 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<T> Option<T> {
     /// 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