Skip to content

Commit 9cb7b3f

Browse files
committed
Auto merge of #25922 - tshepang:better-map-or-doc, r=Gankro
`def` is also ambiguous
2 parents 16d0378 + eb3566f commit 9cb7b3f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/libcore/option.rs

+8-6
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,8 @@ impl<T> Option<T> {
422422
}
423423
}
424424

425-
/// Applies a function to the contained value or returns a default.
425+
/// Applies a function to the contained value (if any),
426+
/// or returns a `default` (if not).
426427
///
427428
/// # Examples
428429
///
@@ -435,14 +436,15 @@ impl<T> Option<T> {
435436
/// ```
436437
#[inline]
437438
#[stable(feature = "rust1", since = "1.0.0")]
438-
pub fn map_or<U, F: FnOnce(T) -> U>(self, def: U, f: F) -> U {
439+
pub fn map_or<U, F: FnOnce(T) -> U>(self, default: U, f: F) -> U {
439440
match self {
440441
Some(t) => f(t),
441-
None => def
442+
None => default,
442443
}
443444
}
444445

445-
/// Applies a function to the contained value or computes a default.
446+
/// Applies a function to the contained value (if any),
447+
/// or computes a `default` (if not).
446448
///
447449
/// # Examples
448450
///
@@ -457,10 +459,10 @@ impl<T> Option<T> {
457459
/// ```
458460
#[inline]
459461
#[stable(feature = "rust1", since = "1.0.0")]
460-
pub fn map_or_else<U, D: FnOnce() -> U, F: FnOnce(T) -> U>(self, def: D, f: F) -> U {
462+
pub fn map_or_else<U, D: FnOnce() -> U, F: FnOnce(T) -> U>(self, default: D, f: F) -> U {
461463
match self {
462464
Some(t) => f(t),
463-
None => def()
465+
None => default()
464466
}
465467
}
466468

0 commit comments

Comments
 (0)