Skip to content

Commit

Permalink
add same warning to Result::expect as Result::unwrap
Browse files Browse the repository at this point in the history
  • Loading branch information
CleanCut committed Jul 22, 2022
1 parent 62b272d commit 7ba0be8
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions library/core/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7ba0be8

Please sign in to comment.