pub trait OptionExt<T> {
// Required method
fn is_none_or(self, f: impl FnOnce(T) -> bool) -> bool;
}Required Methods§
Sourcefn is_none_or(self, f: impl FnOnce(T) -> bool) -> bool
fn is_none_or(self, f: impl FnOnce(T) -> bool) -> bool
Returns true if the option is a None or the value inside of it matches a predicate.
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);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.