1 unstable release

0.1.0 Nov 15, 2023

#26 in #predicate

Download history 902/week @ 2024-11-16 162/week @ 2024-11-23 129/week @ 2024-11-30 101/week @ 2024-12-07 116/week @ 2024-12-14 1/week @ 2024-12-21 5/week @ 2024-12-28 13/week @ 2025-01-04 25/week @ 2025-01-11 12/week @ 2025-01-18 9/week @ 2025-01-25 81/week @ 2025-02-01 28/week @ 2025-02-08 83/week @ 2025-02-15 86/week @ 2025-02-22 54/week @ 2025-03-01

296 downloads per month

MIT/Apache

4KB

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);

lib.rs:

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);

No runtime deps