add same warning to Result::expect as Result::unwrap
This commit is contained in:
parent
62b272d25c
commit
7ba0be832a
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user