pub trait Truthy {
// Required method
fn truthy(&self) -> bool;
// Provided methods
fn falsy(&self) -> bool { ... }
fn truthy_or<T>(self, other: T) -> Either<Self, T>
where Self: Sized { ... }
fn truthy_and<T>(self, other: T) -> Option<T>
where Self: Sized { ... }
}
Expand description
Convert to a bool
.
Required Methods§
Provided Methods§
Sourcefn truthy_or<T>(self, other: T) -> Either<Self, T>where
Self: Sized,
fn truthy_or<T>(self, other: T) -> Either<Self, T>where
Self: Sized,
Left(self)
if self
is truthy, else Right(other)
assert_eq!(true.truthy_or('t').left(), Some(true));
assert_eq!(false.truthy_or('t').right(), Some('t'));
Sourcefn truthy_and<T>(self, other: T) -> Option<T>where
Self: Sized,
fn truthy_and<T>(self, other: T) -> Option<T>where
Self: Sized,
Some(other)
if self
is truthy, else None
assert_eq!(true.truthy_and('t'), Some('t'));
assert_eq!(false.truthy_and('t'), None);