about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-04-05 13:13:10 +0200
committerGitHub <noreply@github.com>2020-04-05 13:13:10 +0200
commit6f595e871339b140c8a0c0f2d13a48a1970d1690 (patch)
tree8219ef212d95adb0e54664f3030a5aa9d80f8e5c
parent7e4ed72d64eb7a6bd6a05d4f3222aa43975898e1 (diff)
parentb4f416d837174f76cb66af731323f7414f198d8e (diff)
downloadrust-6f595e871339b140c8a0c0f2d13a48a1970d1690.tar.gz
rust-6f595e871339b140c8a0c0f2d13a48a1970d1690.zip
Rollup merge of #70760 - PonasKovas:docs, r=Dylan-DPC
docs: make the description of Result::map_or more clear

The documentation of [`Result::map_or`](https://doc.rust-lang.org/std/result/enum.Result.html#method.map_or) is very unclear and confusing, probably because it was copied straight from [`Option::map_or`](https://doc.rust-lang.org/std/option/enum.Option.html#method.map_or) and someone forgot to adapt it for Result.
-rw-r--r--src/libcore/result.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libcore/result.rs b/src/libcore/result.rs
index 0087b92f1f2..c7b5777a16e 100644
--- a/src/libcore/result.rs
+++ b/src/libcore/result.rs
@@ -521,14 +521,16 @@ impl<T, E> Result<T, E> {
         }
     }
 
-    /// Applies a function to the contained value (if any),
-    /// or returns the provided default (if not).
+    /// Applies a function to the contained value (if [`Ok`]),
+    /// or returns the provided default (if [`Err`]).
     ///
     /// 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
+    /// [`Ok`]: enum.Result.html#variant.Ok
+    /// [`Err`]: enum.Result.html#variant.Err
     ///
     /// # Examples
     ///