diff --git a/library/core/src/option.rs b/library/core/src/option.rs index e8850176f7cd3..611f4ab38ab33 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -556,14 +556,16 @@ impl Option { /// # Examples /// /// ``` + /// #![feature(is_some_with)] + /// /// let x: Option = Some(2); - /// assert_eq!(x.is_some_with(|x| x > 1), true); + /// assert_eq!(x.is_some_with(|&x| x > 1), true); /// /// let x: Option = Some(0); - /// assert_eq!(x.is_some_with(|x| x > 1), false); + /// assert_eq!(x.is_some_with(|&x| x > 1), false); /// /// let x: Option = None; - /// assert_eq!(x.is_some_with(|x| x > 1), false); + /// assert_eq!(x.is_some_with(|&x| x > 1), false); /// ``` #[must_use] #[inline] diff --git a/library/core/src/result.rs b/library/core/src/result.rs index 9991112e7f553..fbd6d419236ae 100644 --- a/library/core/src/result.rs +++ b/library/core/src/result.rs @@ -547,14 +547,16 @@ impl Result { /// # Examples /// /// ``` + /// #![feature(is_some_with)] + /// /// let x: Result = Ok(2); - /// assert_eq!(x.is_ok_with(|x| x > 1), true); + /// assert_eq!(x.is_ok_with(|&x| x > 1), true); /// /// let x: Result = Ok(0); - /// assert_eq!(x.is_ok_with(|x| x > 1), false); + /// assert_eq!(x.is_ok_with(|&x| x > 1), false); /// /// let x: Result = Err("hey"); - /// assert_eq!(x.is_ok_with(|x| x > 1), false); + /// assert_eq!(x.is_ok_with(|&x| x > 1), false); /// ``` #[must_use] #[inline] @@ -589,16 +591,17 @@ impl Result { /// # Examples /// /// ``` + /// #![feature(is_some_with)] /// use std::io::{Error, ErrorKind}; /// /// let x: Result = Err(Error::new(ErrorKind::NotFound, "!")); /// assert_eq!(x.is_err_with(|x| x.kind() == ErrorKind::NotFound), true); /// /// let x: Result = Err(Error::new(ErrorKind::PermissionDenied, "!")); - /// assert_eq!(x.is_ok_with(|x| x.kind() == ErrorKind::NotFound), false); + /// assert_eq!(x.is_err_with(|x| x.kind() == ErrorKind::NotFound), false); /// /// let x: Result = Ok(123); - /// assert_eq!(x.is_ok_with(|x| x.kind() == ErrorKind::NotFound), false); + /// assert_eq!(x.is_err_with(|x| x.kind() == ErrorKind::NotFound), false); /// ``` #[must_use] #[inline]