From 667f536d87ca71998f5b60235a99779e9b65f4e0 Mon Sep 17 00:00:00 2001 From: aochagavia Date: Fri, 14 Mar 2014 16:45:43 +0100 Subject: [PATCH] Refactored iter (libstd/option.rs) Using as_ref() instead of match --- src/libstd/option.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/libstd/option.rs b/src/libstd/option.rs index 86f8c143a9e99..91be9145640e2 100644 --- a/src/libstd/option.rs +++ b/src/libstd/option.rs @@ -211,10 +211,7 @@ 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