Add must_use annotations to Result::is_ok and is_err

This commit is contained in:
Alex Gaynor 2019-04-02 22:09:56 +00:00 committed by Alex Gaynor
parent 3750348daf
commit ce5d69480a
5 changed files with 12 additions and 8 deletions

View file

@ -178,6 +178,7 @@ impl<T> Option<T> {
/// ```
///
/// [`Some`]: #variant.Some
#[must_use]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn is_some(&self) -> bool {
@ -200,6 +201,7 @@ impl<T> Option<T> {
/// ```
///
/// [`None`]: #variant.None
#[must_use]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn is_none(&self) -> bool {

View file

@ -277,6 +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]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn is_ok(&self) -> bool {
@ -301,6 +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]
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn is_err(&self) -> bool {