is_none_or

Crates.iois_none_or
lib.rsis_none_or
version0.1.0
sourcesrc
created_at2023-11-15 18:55:02.106984
updated_at2023-11-15 18:55:02.106984
descriptionA simple utility function for the Option type
homepagehttps://github.com/PokeJofeJr4th/is_none_or
repositoryhttps://github.com/PokeJofeJr4th/is_none_or
max_upload_size
id1036690
size3,437
(PokeJofeJr4th)

documentation

https://docs.rs/is_none_or

README

Checking conditions with the IsNoneOr trait

The provided is_none_or method is a mirror to the core library's is_some_and method. It returns true if the option is a [None] or the option is [Some] and the value inside of it matches a predicate.

Examples

use is_none_or::IsNoneOr;

let x: Option<u32> = Some(2);
assert_eq!(x.is_none_or(|x| x > 1), true);

let x: Option<u32> = Some(0);
assert_eq!(x.is_none_or(|x| x > 1), false);

let x: Option<u32> = None;
assert_eq!(x.is_none_or(|x| x > 1), true);
Commit count: 2

cargo fmt