Rollup merge of #68886 - tom-a-wagner:master, r=Mark-Simulacrum

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.

Closes #68866
This commit is contained in:
Dylan DPC 2020-02-06 22:38:36 +01:00 committed by GitHub
commit cc3a0e458c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View File

@ -455,6 +455,12 @@ impl<T> Option<T> {
/// Applies a function to the contained value (if any),
/// or returns the provided default (if not).
///
/// Arguments passed to `map_or` are eagerly evaluated; if you are passing
/// the result of a function call, it is recommended to use [`map_or_else`],
/// which is lazily evaluated.
///
/// [`map_or_else`]: #method.map_or_else
///
/// # Examples
///
/// ```

View File

@ -524,6 +524,12 @@ impl<T, E> Result<T, E> {
/// Applies a function to the contained value (if any),
/// or returns the provided default (if not).
///
/// Arguments passed to `map_or` are eagerly evaluated; if you are passing
/// the result of a function call, it is recommended to use [`map_or_else`],
/// which is lazily evaluated.
///
/// [`map_or_else`]: #method.map_or_else
///
/// # Examples
///
/// ```