1
Fork 0

Fix is_some_with tests.

This commit is contained in:
Mara Bos 2022-01-19 00:09:59 +01:00
parent 45dee47fec
commit 5fee3e7a9c
2 changed files with 13 additions and 8 deletions

View file

@ -556,14 +556,16 @@ impl<T> Option<T> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(is_some_with)]
///
/// let x: Option<u32> = Some(2); /// let x: Option<u32> = 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<u32> = Some(0); /// let x: Option<u32> = 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<u32> = None; /// let x: Option<u32> = None;
/// assert_eq!(x.is_some_with(|x| x > 1), false); /// assert_eq!(x.is_some_with(|&x| x > 1), false);
/// ``` /// ```
#[must_use] #[must_use]
#[inline] #[inline]

View file

@ -547,14 +547,16 @@ impl<T, E> Result<T, E> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(is_some_with)]
///
/// let x: Result<u32, &str> = Ok(2); /// let x: Result<u32, &str> = 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<u32, &str> = Ok(0); /// let x: Result<u32, &str> = 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<u32, &str> = Err("hey"); /// let x: Result<u32, &str> = Err("hey");
/// assert_eq!(x.is_ok_with(|x| x > 1), false); /// assert_eq!(x.is_ok_with(|&x| x > 1), false);
/// ``` /// ```
#[must_use] #[must_use]
#[inline] #[inline]
@ -589,16 +591,17 @@ impl<T, E> Result<T, E> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(is_some_with)]
/// use std::io::{Error, ErrorKind}; /// use std::io::{Error, ErrorKind};
/// ///
/// let x: Result<u32, Error> = Err(Error::new(ErrorKind::NotFound, "!")); /// let x: Result<u32, Error> = Err(Error::new(ErrorKind::NotFound, "!"));
/// assert_eq!(x.is_err_with(|x| x.kind() == ErrorKind::NotFound), true); /// assert_eq!(x.is_err_with(|x| x.kind() == ErrorKind::NotFound), true);
/// ///
/// let x: Result<u32, Error> = Err(Error::new(ErrorKind::PermissionDenied, "!")); /// let x: Result<u32, Error> = 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<u32, Error> = Ok(123); /// let x: Result<u32, Error> = 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] #[must_use]
#[inline] #[inline]