diff --git a/src/core/utils/bool.rs b/src/core/utils/bool.rs index 045ee014..66adfa4c 100644 --- a/src/core/utils/bool.rs +++ b/src/core/utils/bool.rs @@ -4,6 +4,12 @@ pub trait BoolExt { fn and(self, t: Option) -> Option; + #[must_use] + fn and_is(self, b: bool) -> bool; + + #[must_use] + fn and_if bool>(self, f: F) -> bool; + fn and_then Option>(self, f: F) -> Option; #[must_use] @@ -55,6 +61,12 @@ impl BoolExt for bool { #[inline] fn and(self, t: Option) -> Option { self.then_some(t).flatten() } + #[inline] + fn and_if Self>(self, f: F) -> Self { self.and_is(f()) } + + #[inline] + fn and_is(self, b: Self) -> Self { self && b } + #[inline] fn and_then Option>(self, f: F) -> Option { self.then(f).flatten() }