about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-04-27 12:21:53 +0000
committerbors <bors@rust-lang.org>2021-04-27 12:21:53 +0000
commit1919b3f22706fee0b2c6ac3d42316545900b7734 (patch)
treee3a6bede1078303ac5df61ea8d50e349592f0088
parentdc8cb63078c1322cef0ac11c2f8b006f6e310a46 (diff)
parent6c22b39187b25d0c2b07e1d85b93107c409a1c41 (diff)
Auto merge of #84609 - lefth:master, r=Dylan-DPC
Reorder the parameter descriptions of map_or and map_or_else

They were described backwards, probably leading users to write arguments in the wrong order. Bug: #84608
-rw-r--r--library/core/src/option.rs8
-rw-r--r--library/core/src/result.rs10
2 files changed, 9 insertions, 9 deletions
diff --git a/library/core/src/option.rs b/library/core/src/option.rs
index 9c527eff491..04551dded8c 100644
--- a/library/core/src/option.rs
+++ b/library/core/src/option.rs
@@ -489,8 +489,8 @@ impl<T> Option<T> {
         }
     }
 
-    /// Applies a function to the contained value (if any),
-    /// or returns the provided default (if not).
+    /// Returns the provided default result (if none),
+    /// or applies a function to the contained value (if any).
     ///
     /// 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`],
@@ -516,8 +516,8 @@ impl<T> Option<T> {
         }
     }
 
-    /// Applies a function to the contained value (if any),
-    /// or computes a default (if not).
+    /// Computes a default function result (if none), or
+    /// applies a different function to the contained value (if any).
     ///
     /// # Examples
     ///
diff --git a/library/core/src/result.rs b/library/core/src/result.rs
index bac02104c34..e0071f806aa 100644
--- a/library/core/src/result.rs
+++ b/library/core/src/result.rs
@@ -506,8 +506,8 @@ impl<T, E> Result<T, E> {
         }
     }
 
-    /// Applies a function to the contained value (if [`Ok`]),
-    /// or returns the provided default (if [`Err`]).
+    /// Returns the provided default (if [`Err`]), or
+    /// applies a function to the contained value (if [`Ok`]),
     ///
     /// 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`],
@@ -533,9 +533,9 @@ impl<T, E> Result<T, E> {
         }
     }
 
-    /// Maps a `Result<T, E>` to `U` by applying a function to a
-    /// contained [`Ok`] value, or a fallback function to a
-    /// contained [`Err`] value.
+    /// Maps a `Result<T, E>` to `U` by applying a fallback function to a
+    /// contained [`Err`] value, or a default function to a
+    /// contained [`Ok`] value.
     ///
     /// This function can be used to unpack a successful result
     /// while handling an error.