additional stream tools

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk authored and strawberry committed 2024-10-25 00:36:30 -04:00
1 parent a8d5cf9651
commit 6b80361c31
10 files changed
+242 -46

No files matched your search

+16
View File
@@ -0,0 +1,16 @@
//! Trait BoolExt
/// Boolean extensions and chain.starters
pub trait BoolExt {
fn or<T, F: FnOnce() -> T>(self, f: F) -> Option<T>;
fn or_some<T>(self, t: T) -> Option<T>;
}
impl BoolExt for bool {
#[inline]
fn or<T, F: FnOnce() -> T>(self, f: F) -> Option<T> { (!self).then(f) }
#[inline]
fn or_some<T>(self, t: T) -> Option<T> { (!self).then_some(t) }
}