is_none_or 0.1.0

A simple utility function for the Option type
Documentation
  • Coverage
  • 33.33%
    1 out of 3 items documented1 out of 3 items with examples
  • Size
  • Source code size: 3.43 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 121.55 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 7s Average build duration of successful builds.
  • all releases: 7s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • PokeJofeJr4th/is_none_or
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • PokeJofeJr4th

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