Skip to content

Commit

Permalink
Fix is_some_with tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ou-se committed Jan 18, 2022
1 parent 45dee47 commit 5fee3e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
8 changes: 5 additions & 3 deletions library/core/src/option.rs
Expand Up @@ -556,14 +556,16 @@ impl<T> Option<T> {
/// # Examples
///
/// ```
/// #![feature(is_some_with)]
///
/// 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);
/// 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;
/// assert_eq!(x.is_some_with(|x| x > 1), false);
/// assert_eq!(x.is_some_with(|&x| x > 1), false);
/// ```
#[must_use]
#[inline]
Expand Down
13 changes: 8 additions & 5 deletions library/core/src/result.rs
Expand Up @@ -547,14 +547,16 @@ impl<T, E> Result<T, E> {
/// # Examples
///
/// ```
/// #![feature(is_some_with)]
///
/// 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);
/// 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");
/// assert_eq!(x.is_ok_with(|x| x > 1), false);
/// assert_eq!(x.is_ok_with(|&x| x > 1), false);
/// ```
#[must_use]
#[inline]
Expand Down Expand Up @@ -589,16 +591,17 @@ impl<T, E> Result<T, E> {
/// # Examples
///
/// ```
/// #![feature(is_some_with)]
/// use std::io::{Error, ErrorKind};
///
/// let x: Result<u32, Error> = Err(Error::new(ErrorKind::NotFound, "!"));
/// assert_eq!(x.is_err_with(|x| x.kind() == ErrorKind::NotFound), true);
///
/// 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);
/// 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]
Expand Down

0 comments on commit 5fee3e7

Please sign in to comment.