mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2025-07-28 10:48:30 +00:00
17 lines
367 B
Rust
17 lines
367 B
Rust
|
//! 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) }
|
||
|
}
|