about summary refs log tree commit diff
diff options
context:
space:
mode:
authorStuart Cook <Zalathar@users.noreply.github.com>2025-08-19 14:18:17 +1000
committerGitHub <noreply@github.com>2025-08-19 14:18:17 +1000
commit0671b2fe49e8d3871ce6949757f52d3b1d85e8b8 (patch)
tree7d7c0d7a6934ee7ca10274acf247ff2e6de7f173
parent633cc0cc6cfc6b77da14864dbefb1dab25dcb8d0 (diff)
parent06ae1bee205c9f85cc89047568737a87c791a032 (diff)
downloadrust-0671b2fe49e8d3871ce6949757f52d3b1d85e8b8.tar.gz
rust-0671b2fe49e8d3871ce6949757f52d3b1d85e8b8.zip
Rollup merge of #142871 - chenyukang:yukang-fix-doc-for-transpose, r=ibraheemdev
Trivial improve doc for transpose

When I saw old doc, I felt a little confused.
Seems it would be clearer this way.
-rw-r--r--library/core/src/option.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/library/core/src/option.rs b/library/core/src/option.rs
index 560d20ce617..e83e77344cf 100644
--- a/library/core/src/option.rs
+++ b/library/core/src/option.rs
@@ -2095,9 +2095,9 @@ impl<T> Option<&mut T> {
 impl<T, E> Option<Result<T, E>> {
     /// Transposes an `Option` of a [`Result`] into a [`Result`] of an `Option`.
     ///
-    /// [`None`] will be mapped to <code>[Ok]\([None])</code>.
-    /// <code>[Some]\([Ok]\(\_))</code> and <code>[Some]\([Err]\(\_))</code> will be mapped to
-    /// <code>[Ok]\([Some]\(\_))</code> and <code>[Err]\(\_)</code>.
+    /// <code>[Some]\([Ok]\(\_))</code> is mapped to <code>[Ok]\([Some]\(\_))</code>,
+    /// <code>[Some]\([Err]\(\_))</code> is mapped to <code>[Err]\(\_)</code>,
+    /// and [`None`] will be mapped to <code>[Ok]\([None])</code>.
     ///
     /// # Examples
     ///
@@ -2105,9 +2105,9 @@ impl<T, E> Option<Result<T, E>> {
     /// #[derive(Debug, Eq, PartialEq)]
     /// struct SomeErr;
     ///
-    /// let x: Result<Option<i32>, SomeErr> = Ok(Some(5));
-    /// let y: Option<Result<i32, SomeErr>> = Some(Ok(5));
-    /// assert_eq!(x, y.transpose());
+    /// let x: Option<Result<i32, SomeErr>> = Some(Ok(5));
+    /// let y: Result<Option<i32>, SomeErr> = Ok(Some(5));
+    /// assert_eq!(x.transpose(), y);
     /// ```
     #[inline]
     #[stable(feature = "transpose_result", since = "1.33.0")]