1 unstable release

0.1.0 Nov 15, 2023

#2901 in Rust patterns

Download history 597/week @ 2024-06-02 498/week @ 2024-06-09 747/week @ 2024-06-16 519/week @ 2024-06-23 1141/week @ 2024-06-30 469/week @ 2024-07-07 693/week @ 2024-07-14 489/week @ 2024-07-21 1065/week @ 2024-07-28 1190/week @ 2024-08-04 558/week @ 2024-08-11 539/week @ 2024-08-18 672/week @ 2024-08-25 570/week @ 2024-09-01 882/week @ 2024-09-08 731/week @ 2024-09-15

2,856 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