Skip to content

Commit d646463

Browse files
committed
Mark fn map_or() as eagerly evaluated.
In the docs for option.rs and result.rs, it is noted for all *_or() functions that they are eagerly evaluated, except for the map_or() function. This commit adds this missing documentation to the two files.
1 parent 1f8df25 commit d646463

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/libcore/option.rs

+6
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,12 @@ impl<T> Option<T> {
455455
/// Applies a function to the contained value (if any),
456456
/// or returns the provided default (if not).
457457
///
458+
/// Arguments passed to `map_or` are eagerly evaluated; if you are passing
459+
/// the result of a function call, it is recommended to use [`map_or_else`],
460+
/// which is lazily evaluated.
461+
///
462+
/// [`map_or_else`]: #method.map_or_else
463+
///
458464
/// # Examples
459465
///
460466
/// ```

src/libcore/result.rs

+6
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,12 @@ impl<T, E> Result<T, E> {
524524
/// Applies a function to the contained value (if any),
525525
/// or returns the provided default (if not).
526526
///
527+
/// Arguments passed to `map_or` are eagerly evaluated; if you are passing
528+
/// the result of a function call, it is recommended to use [`map_or_else`],
529+
/// which is lazily evaluated.
530+
///
531+
/// [`map_or_else`]: #method.map_or_else
532+
///
527533
/// # Examples
528534
///
529535
/// ```

0 commit comments

Comments
 (0)