mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-14 04:37:00 +00:00
1 parent
a8d5cf9651
commit
6b80361c31
10 files changed
+242
-46
No files matched your search
@@ -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) }
|
||||
}
|
||||
Reference in new issue
Block a user