Skip to content

Commit

Permalink
Mark fn map_or() as eagerly evaluated.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
tom-a-wagner committed Feb 6, 2020
1 parent 1f8df25 commit d646463
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
/// ```
Expand Down
6 changes: 6 additions & 0 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
/// ```
Expand Down

0 comments on commit d646463

Please sign in to comment.