Trait stry_common::utils::fenn::BoolExt [−][src]
Various extensions to the bool primitive.
Required methods
fn some<T>(self, t: T) -> Option<T>[src]
A stable version of then_some.
Returns Some(t) if the bool is true, or None otherwise.
Examples
use fenn::BoolExt; assert_eq!(false.some(0), None); assert_eq!(true.some(0), Some(0));
fn some_with<T, F>(self, run: F) -> Option<T> where
F: FnOnce() -> T, [src]
F: FnOnce() -> T,
A stable version of then.
Returns Some(f()) if the bool is true, or None otherwise.
Examples
use fenn::BoolExt; assert_eq!(false.some_with(|| 0), None); assert_eq!(true.some_with(|| 0), Some(0));
fn as_option(self) -> Option<()>[src]
Returns Some(()) if the bool is true, or None otherwise.
Examples
use fenn::BoolExt; assert!(false.as_option().is_none()); assert!(true.as_option().is_some());
fn ok<T>(self, t: T) -> Result<T, ()>[src]
Returns Ok(t) if the bool is true, or Er(()) otherwise.
Examples
use fenn::BoolExt; assert_eq!(false.ok(0), Err(())); assert_eq!(true.ok(0), Ok(0));
fn ok_with<T, F>(self, run: F) -> Result<T, ()> where
F: FnOnce() -> T, [src]
F: FnOnce() -> T,
Returns Ok(run()) if the bool is true, or Er(()) otherwise.
Examples
use fenn::BoolExt; assert_eq!(false.ok_with(|| 0), Err(())); assert_eq!(true.ok_with(|| 0), Ok(0));
fn as_result(self) -> Result<(), ()>[src]
Returns Ok(()) if the bool is true, or Err(()) otherwise.
Implementations on Foreign Types
impl BoolExt for bool[src]
fn some<T>(self, t: T) -> Option<T>[src]
fn some_with<T, F>(self, run: F) -> Option<T> where
F: FnOnce() -> T, [src]
F: FnOnce() -> T,
fn as_option(self) -> Option<()>[src]
fn ok<T>(self, t: T) -> Result<T, ()>[src]
fn ok_with<T, F>(self, run: F) -> Result<T, ()> where
F: FnOnce() -> T, [src]
F: FnOnce() -> T,