update option and result references to expect message docs
This commit is contained in:
parent
b6b621ec85
commit
720e987ac0
2 changed files with 27 additions and 5 deletions
|
@ -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")]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue