about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--library/core/src/result.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/library/core/src/result.rs b/library/core/src/result.rs
index 8a68cdf7d65..45b052c824d 100644
--- a/library/core/src/result.rs
+++ b/library/core/src/result.rs
@@ -1009,6 +1009,15 @@ impl<T, E> Result<T, E> {
 
     /// Returns the contained [`Ok`] value, consuming the `self` value.
     ///
+    /// Because this function may panic, its use is generally discouraged.
+    /// Instead, prefer to use pattern matching and handle the [`Err`]
+    /// case explicitly, or call [`unwrap_or`], [`unwrap_or_else`], or
+    /// [`unwrap_or_default`].
+    ///
+    /// [`unwrap_or`]: Result::unwrap_or
+    /// [`unwrap_or_else`]: Result::unwrap_or_else
+    /// [`unwrap_or_default`]: Result::unwrap_or_default
+    ///
     /// # Panics
     ///
     /// Panics if the value is an [`Err`], with a panic message including the