about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-11-17 02:56:55 +0000
committerbors <bors@rust-lang.org>2014-11-17 02:56:55 +0000
commit803aacd5aef78f90fdd06ae7653fc20eec224992 (patch)
tree2088be9de347fd4961bd5c1457383d0aef91d811
parent0b7b4f075a531eb160becf2818c1e9a63fa10cd3 (diff)
parent4aa2040cc71d1a0394a2845e5b0959655e2a3ecb (diff)
downloadrust-803aacd5aef78f90fdd06ae7653fc20eec224992.tar.gz
rust-803aacd5aef78f90fdd06ae7653fc20eec224992.zip
auto merge of #18927 : areski/rust/pr-improve-option-match-readl, r=jakub-
**match** are much more easy to read when it's not in 1 single line
-rw-r--r--src/libcore/option.rs25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/libcore/option.rs b/src/libcore/option.rs
index d41dbb11adb..af9efee0c8f 100644
--- a/src/libcore/option.rs
+++ b/src/libcore/option.rs
@@ -235,7 +235,10 @@ impl<T> Option<T> {
     #[inline]
     #[stable]
     pub fn as_ref<'r>(&'r self) -> Option<&'r T> {
-        match *self { Some(ref x) => Some(x), None => None }
+        match *self {
+            Some(ref x) => Some(x),
+            None => None
+        }
     }
 
     /// Convert from `Option<T>` to `Option<&mut T>`
@@ -253,7 +256,10 @@ impl<T> Option<T> {
     #[inline]
     #[unstable = "waiting for mut conventions"]
     pub fn as_mut<'r>(&'r mut self) -> Option<&'r mut T> {
-        match *self { Some(ref mut x) => Some(x), None => None }
+        match *self {
+            Some(ref mut x) => Some(x),
+            None => None
+        }
     }
 
     /// Convert from `Option<T>` to `&mut [T]` (without copying)
@@ -401,7 +407,10 @@ impl<T> Option<T> {
     #[inline]
     #[unstable = "waiting for unboxed closures"]
     pub fn map<U>(self, f: |T| -> U) -> Option<U> {
-        match self { Some(x) => Some(f(x)), None => None }
+        match self {
+            Some(x) => Some(f(x)),
+            None => None
+        }
     }
 
     /// Applies a function to the contained value or returns a default.
@@ -418,7 +427,10 @@ impl<T> Option<T> {
     #[inline]
     #[unstable = "waiting for unboxed closures"]
     pub fn map_or<U>(self, def: U, f: |T| -> U) -> U {
-        match self { None => def, Some(t) => f(t) }
+        match self {
+            Some(t) => f(t),
+            None => def
+        }
     }
 
     /// Applies a function to the contained value or computes a default.
@@ -437,7 +449,10 @@ impl<T> Option<T> {
     #[inline]
     #[unstable = "waiting for unboxed closures"]
     pub fn map_or_else<U>(self, def: || -> U, f: |T| -> U) -> U {
-        match self { None => def(), Some(t) => f(t) }
+        match self {
+            Some(t) => f(t),
+            None => def()
+        }
     }
 
     /// Transforms the `Option<T>` into a `Result<T, E>`, mapping `Some(v)` to