From 5ab843fbc3924fc7706f8adf281da7aff3dced31 Mon Sep 17 00:00:00 2001
From: Erick Tryzelaar <erick.tryzelaar@gmail.com>
Date: Fri, 13 Sep 2013 16:38:36 -0700
Subject: [PATCH 1/2] std: Remove Option.or_{default,zero}

These can be replaced with `Some(option.or_default())`.
---
 src/libstd/option.rs | 20 +-------------------
 1 file changed, 1 insertion(+), 19 deletions(-)

diff --git a/src/libstd/option.rs b/src/libstd/option.rs
index 9b6d0a77cd8..42878f6effb 100644
--- a/src/libstd/option.rs
+++ b/src/libstd/option.rs
@@ -467,15 +467,6 @@ impl<T: Default> Option<T> {
             None => Default::default()
         }
     }
-
-    /// Returns self or `Some`-wrapped default value
-    #[inline]
-    pub fn or_default(self) -> Option<T> {
-        match self {
-            None => Some(Default::default()),
-            x => x,
-        }
-    }
 }
 
 impl<T> Default for Option<T> {
@@ -483,7 +474,7 @@ impl<T> Default for Option<T> {
     fn default() -> Option<T> { None }
 }
 
-impl<T:Zero> Option<T> {
+impl<T: Zero> Option<T> {
     /// Returns the contained value or zero (for this type)
     #[inline]
     pub fn unwrap_or_zero(self) -> T {
@@ -492,15 +483,6 @@ impl<T:Zero> Option<T> {
             None => Zero::zero()
         }
     }
-
-    /// Returns self or `Some`-wrapped zero value
-    #[inline]
-    pub fn or_zero(self) -> Option<T> {
-        match self {
-            None => Some(Zero::zero()),
-            x => x
-        }
-    }
 }
 
 /// An iterator that yields either one or zero elements

From 1a90f24bbdd4decec3df35d628fdb8825675190a Mon Sep 17 00:00:00 2001
From: Erick Tryzelaar <erick.tryzelaar@gmail.com>
Date: Tue, 17 Sep 2013 21:02:17 -0700
Subject: [PATCH 2/2] extra: minor cleanup of Zero and Default syntax extension

---
 src/libsyntax/ext/deriving/default.rs | 8 +++-----
 src/libsyntax/ext/deriving/zero.rs    | 8 +++-----
 2 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/src/libsyntax/ext/deriving/default.rs b/src/libsyntax/ext/deriving/default.rs
index 0c7bbefc690..d8c78842808 100644
--- a/src/libsyntax/ext/deriving/default.rs
+++ b/src/libsyntax/ext/deriving/default.rs
@@ -47,9 +47,7 @@ fn default_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Exp
         cx.ident_of("Default"),
         cx.ident_of("default")
     ];
-    let default_call = || {
-        cx.expr_call_global(span, default_ident.clone(), ~[])
-    };
+    let default_call = cx.expr_call_global(span, default_ident.clone(), ~[]);
 
     return match *substr.fields {
         StaticStruct(_, ref summary) => {
@@ -58,13 +56,13 @@ fn default_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Exp
                     if count == 0 {
                         cx.expr_ident(span, substr.type_ident)
                     } else {
-                        let exprs = vec::from_fn(count, |_| default_call());
+                        let exprs = vec::from_elem(count, default_call);
                         cx.expr_call_ident(span, substr.type_ident, exprs)
                     }
                 }
                 Right(ref fields) => {
                     let default_fields = do fields.map |ident| {
-                        cx.field_imm(span, *ident, default_call())
+                        cx.field_imm(span, *ident, default_call)
                     };
                     cx.expr_struct_ident(span, substr.type_ident, default_fields)
                 }
diff --git a/src/libsyntax/ext/deriving/zero.rs b/src/libsyntax/ext/deriving/zero.rs
index fc527d44b53..2546cfc2e39 100644
--- a/src/libsyntax/ext/deriving/zero.rs
+++ b/src/libsyntax/ext/deriving/zero.rs
@@ -62,9 +62,7 @@ fn zero_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
         cx.ident_of("Zero"),
         cx.ident_of("zero")
     ];
-    let zero_call = || {
-        cx.expr_call_global(span, zero_ident.clone(), ~[])
-    };
+    let zero_call = cx.expr_call_global(span, zero_ident.clone(), ~[]);
 
     return match *substr.fields {
         StaticStruct(_, ref summary) => {
@@ -73,13 +71,13 @@ fn zero_substructure(cx: @ExtCtxt, span: Span, substr: &Substructure) -> @Expr {
                     if count == 0 {
                         cx.expr_ident(span, substr.type_ident)
                     } else {
-                        let exprs = vec::from_fn(count, |_| zero_call());
+                        let exprs = vec::from_elem(count, zero_call);
                         cx.expr_call_ident(span, substr.type_ident, exprs)
                     }
                 }
                 Right(ref fields) => {
                     let zero_fields = do fields.map |ident| {
-                        cx.field_imm(span, *ident, zero_call())
+                        cx.field_imm(span, *ident, zero_call)
                     };
                     cx.expr_struct_ident(span, substr.type_ident, zero_fields)
                 }