diff options
| author | bors <bors@rust-lang.org> | 2015-06-01 00:45:44 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-06-01 00:45:44 +0000 |
| commit | 9cb7b3ffb6522a5fa4d3666b5859d4122c918e44 (patch) | |
| tree | f4a9ead3594298ea08b1ef6978558b8149aadfc3 /src/libcore | |
| parent | 16d037866d1fc5b478e40d92e4f76b2ecb8c4d79 (diff) | |
| parent | eb3566f239f02c4d7dbd7b8d8cb33fe4455347bd (diff) | |
| download | rust-9cb7b3ffb6522a5fa4d3666b5859d4122c918e44.tar.gz rust-9cb7b3ffb6522a5fa4d3666b5859d4122c918e44.zip | |
Auto merge of #25922 - tshepang:better-map-or-doc, r=Gankro
`def` is also ambiguous
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/option.rs | 14 |
1 files 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 @@ impl<T> Option<T> { } } - /// 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 @@ impl<T> Option<T> { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn map_or<U, F: FnOnce(T) -> U>(self, def: U, f: F) -> U { + pub fn map_or<U, F: FnOnce(T) -> 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 @@ impl<T> Option<T> { /// ``` #[inline] #[stable(feature = "rust1", since = "1.0.0")] - pub fn map_or_else<U, D: FnOnce() -> U, F: FnOnce(T) -> U>(self, def: D, f: F) -> U { + pub fn map_or_else<U, D: FnOnce() -> U, F: FnOnce(T) -> U>(self, default: D, f: F) -> U { match self { Some(t) => f(t), - None => def() + None => default() } } |
