1 unstable release

0.1.0 Nov 15, 2023

#2905 in Rust patterns

Download history 536/week @ 2024-07-19 991/week @ 2024-07-26 1267/week @ 2024-08-02 629/week @ 2024-08-09 542/week @ 2024-08-16 623/week @ 2024-08-23 632/week @ 2024-08-30 628/week @ 2024-09-06 852/week @ 2024-09-13 671/week @ 2024-09-20 483/week @ 2024-09-27 710/week @ 2024-10-04 791/week @ 2024-10-11 691/week @ 2024-10-18 771/week @ 2024-10-25 799/week @ 2024-11-01

3,172 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