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.
This commit is contained in:
Tom A. Wagner 2020-02-06 12:09:16 +01:00
parent 1f8df2508f
commit d646463a45
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
///
/// ```