From eb3566f239f02c4d7dbd7b8d8cb33fe4455347bd Mon Sep 17 00:00:00 2001 From: Tshepang Lekhonkhobe Date: Sun, 31 May 2015 10:16:49 +0200 Subject: [PATCH] doc: improve map_or and map_or_else --- src/libcore/option.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 8da28094be3..9e7c6fa0301 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -422,7 +422,8 @@ pub fn map U>(self, f: F) -> Option { } } - /// Applies a function to the contained value or returns a default. + /// Applies a function to the contained value (if any), + /// or returns a `default` (if not). /// /// # Examples /// @@ -435,14 +436,15 @@ pub fn map U>(self, f: F) -> Option { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn map_or U>(self, def: U, f: F) -> U { + pub fn map_or U>(self, default: U, f: F) -> U { match self { Some(t) => f(t), - None => def + None => default, } } - /// Applies a function to the contained value or computes a default. + /// Applies a function to the contained value (if any), + /// or computes a `default` (if not). /// /// # Examples /// @@ -457,10 +459,10 @@ pub fn map_or U>(self, def: U, f: F) -> U { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn map_or_else U, F: FnOnce(T) -> U>(self, def: D, f: F) -> U { + pub fn map_or_else U, F: FnOnce(T) -> U>(self, default: D, f: F) -> U { match self { Some(t) => f(t), - None => def() + None => default() } }