diff options
| author | Dylan DPC <dylan.dpc@gmail.com> | 2020-02-06 22:38:36 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-06 22:38:36 +0100 |
| commit | cc3a0e458c64612dd4b8bb4257ab4648c86548bb (patch) | |
| tree | 3ed866ae68d1ce9b81a9d80ad19ec6505eb8138d /src/libcore | |
| parent | 4ce157d008ada410654bc5dffe2674e879fd1960 (diff) | |
| parent | d646463a452d77dd7d5e1f8d0830d95bf867863f (diff) | |
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
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/option.rs | 6 | ||||
| -rw-r--r-- | src/libcore/result.rs | 6 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/libcore/option.rs b/src/libcore/option.rs index ad0491f888c..e35c91206b8 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -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 /// /// ``` diff --git a/src/libcore/result.rs b/src/libcore/result.rs index bc70dbd62eb..809d4bace8e 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -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 /// /// ``` |
