diff options
| author | Chris Gregory <czipperz@gmail.com> | 2019-07-05 20:57:25 -0700 |
|---|---|---|
| committer | Chris Gregory <czipperz@gmail.com> | 2019-07-05 20:57:25 -0700 |
| commit | 145385e7c3fbb242e3024ad0368f2cfd95f5666e (patch) | |
| tree | 8a1646bb9b3c871bf6cb62f1ffe7b4b3e779dc6c | |
| parent | 481068a707679257e2a738b40987246e0420e787 (diff) | |
| download | rust-145385e7c3fbb242e3024ad0368f2cfd95f5666e.tar.gz rust-145385e7c3fbb242e3024ad0368f2cfd95f5666e.zip | |
Add messages to Option and Result must_use for is_*
| -rw-r--r-- | src/libcore/option.rs | 4 | ||||
| -rw-r--r-- | src/libcore/result.rs | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/libcore/option.rs b/src/libcore/option.rs index b27fd4098e1..9174ebae171 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -178,7 +178,7 @@ impl<T> Option<T> { /// ``` /// /// [`Some`]: #variant.Some - #[must_use] + #[must_use = "if you intended to assert that this has a value, consider `.unwrap()` instead"] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn is_some(&self) -> bool { @@ -201,7 +201,7 @@ impl<T> Option<T> { /// ``` /// /// [`None`]: #variant.None - #[must_use] + #[must_use = "if you intended to assert that this doesn't have a value, consider `.and_then(|| panic!(\"`Option` had a value when expected `None`\"))` instead"] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn is_none(&self) -> bool { diff --git a/src/libcore/result.rs b/src/libcore/result.rs index 8a09877ce1f..a31ac212dea 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -277,7 +277,7 @@ impl<T, E> Result<T, E> { /// let x: Result<i32, &str> = Err("Some error message"); /// assert_eq!(x.is_ok(), false); /// ``` - #[must_use] + #[must_use = "if you intended to assert that this is ok, consider `.unwrap()` instead"] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn is_ok(&self) -> bool { @@ -302,7 +302,7 @@ impl<T, E> Result<T, E> { /// let x: Result<i32, &str> = Err("Some error message"); /// assert_eq!(x.is_err(), true); /// ``` - #[must_use] + #[must_use = "if you intended to assert that this is err, consider `.unwrap_err()` instead"] #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub fn is_err(&self) -> bool { |
