update option and result references to expect message docs
This commit is contained in:
parent
b6b621ec85
commit
720e987ac0
@ -709,8 +709,24 @@ impl<T> Option<T> {
|
||||
/// x.expect("fruits are healthy"); // panics with `fruits are healthy`
|
||||
/// ```
|
||||
///
|
||||
/// **Note**: Please refer to the documentation on [`Result::expect`] for further information
|
||||
/// on common message styles.
|
||||
/// # Recommended Message Style
|
||||
///
|
||||
/// We recommend that `expect` messages are used to describe the reason you
|
||||
/// _expect_ the `Option` should be `Some`.
|
||||
///
|
||||
/// ```should_panic
|
||||
/// let item = slice.get(0)
|
||||
/// .expect("slice should not be empty");
|
||||
/// ```
|
||||
///
|
||||
/// **Hint**: If you're having trouble remembering how to phrase expect
|
||||
/// error messages remember to focus on the word "should" as in "env
|
||||
/// variable should be set by blah" or "the given binary should be available
|
||||
/// and executable by the current user".
|
||||
///
|
||||
/// For more detail on expect message styles and the reasoning behind our
|
||||
/// recommendation please refer to the section on ["Common Message
|
||||
/// Styles"](../../std/error/index.html#common-message-styles) in the [`std::error`](../../std/error/index.html) module docs.
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
@ -1034,9 +1034,15 @@ impl<T, E> Result<T, E> {
|
||||
/// .expect("env variable `IMPORTANT_PATH` should be set by `wrapper_script.sh`");
|
||||
/// ```
|
||||
///
|
||||
/// For more detail on expect message styles and the reasoning behind our
|
||||
/// recommendation please refer to the section on ["Common Message
|
||||
/// Styles"]() in the [`std::error`]() module docs.
|
||||
/// **Hint**: If you're having trouble remembering how to phrase expect
|
||||
/// error messages remember to focus on the word "should" as in "env
|
||||
/// variable should be set by blah" or "the given binary should be available
|
||||
/// and executable by the current user".
|
||||
///
|
||||
/// For more detail on expect message styles and the reasoning behind our recommendation please
|
||||
/// refer to the section on ["Common Message
|
||||
/// Styles"](../../std/error/index.html#common-message-styles) in the
|
||||
/// [`std::error`](../../std/error/index.html) module docs.
|
||||
#[inline]
|
||||
#[track_caller]
|
||||
#[stable(feature = "result_expect", since = "1.4.0")]
|
||||
|
Loading…
x
Reference in New Issue
Block a user